_id
stringlengths 2
7
| title
stringlengths 1
118
| partition
stringclasses 3
values | text
stringlengths 52
85.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q182400 | RemoveTag | test | func (s *DeploymentManifest) RemoveTag(key string) {
if s.Tags != nil {
delete(s.Tags, key)
}
} | go | {
"resource": ""
} |
q182401 | LoadPivnetRelease | test | func LoadPivnetRelease(releaseRepo pull.Release, path string) (release *PivnetRelease, err error) {
release = &PivnetRelease{}
var localPath string
localPath, err = releaseRepo.Pull(path)
if err != nil {
return
}
release = &PivnetRelease{
BoshRelease: make(map[string]*BoshRelease),
}
err = release.readPivnetRelease(localPath)
return
} | go | {
"resource": ""
} |
q182402 | BoshReleaseOrEmpty | test | func (r *PivnetRelease) BoshReleaseOrEmpty(name string) *BoshRelease {
br := r.BoshRelease[name]
if br == nil {
br = emptyBoshRelease
}
return br
} | go | {
"resource": ""
} |
q182403 | readPivnetRelease | test | func (r *PivnetRelease) readPivnetRelease(path string) error {
walker := pkg.NewZipWalker(path)
walker.OnMatch("releases/", func(file pkg.FileEntry) error {
br, berr := readBoshRelease(file.Reader)
if berr != nil {
return berr
}
r.BoshRelease[br.ReleaseManifest.Name] = br
return nil
})
return walker.Walk()
} | go | {
"resource": ""
} |
q182404 | decodeYaml | test | func decodeYaml(r io.Reader, v interface{}) error {
bytes, err := ioutil.ReadAll(r)
if err == nil {
yaml.Unmarshal(bytes, v)
}
return err
} | go | {
"resource": ""
} |
q182405 | NewZipWalker | test | func NewZipWalker(zipFile string) Walker {
return zipWalker{
zipPath: zipFile,
callbacks: make(map[*regexp.Regexp]WalkFunc),
}
} | go | {
"resource": ""
} |
q182406 | NewDiffCmd | test | func NewDiffCmd(releaseRepo pull.Release, release1, release2 string) *DiffCmd {
return &DiffCmd{
releaseRepo: releaseRepo,
release1: release1,
release2: release2,
}
} | go | {
"resource": ""
} |
q182407 | All | test | func (s *DiffCmd) All(w io.Writer) error {
differ, err := diff.New(s.releaseRepo, s.release1, s.release2)
if err != nil {
return err
}
d, err := differ.Diff()
if err != nil {
return err
}
s.printDiffResult(w, d)
return nil
} | go | {
"resource": ""
} |
q182408 | Job | test | func (s *DiffCmd) Job(job string, w io.Writer) error {
differ, err := diff.New(s.releaseRepo, s.release1, s.release2)
if err != nil {
return err
}
d, err := differ.DiffJob(job)
if err != nil {
return err
}
s.printDiffResult(w, d)
return nil
} | go | {
"resource": ""
} |
q182409 | New | test | func New(releaseRepo pull.Release, r1Path, r2Path string) (differ Differ, err error) {
if filepath.Ext(r1Path) != filepath.Ext(r2Path) {
err = fmt.Errorf("The specified releases didn't have matching file extensions, " +
"assuming different release types.")
return
}
if filepath.Ext(r1Path) == ".pivotal" {
var r1, r2 *release.PivnetRelease
if r1, err = release.LoadPivnetRelease(releaseRepo, r1Path); err == nil {
if r2, err = release.LoadPivnetRelease(releaseRepo, r2Path); err == nil {
differ = pivnetReleaseDiffer{
release1: r1,
release2: r2,
}
}
}
} else {
var r1, r2 *release.BoshRelease
if r1, err = release.LoadBoshRelease(releaseRepo, r1Path); err == nil {
if r2, err = release.LoadBoshRelease(releaseRepo, r2Path); err == nil {
differ = boshReleaseDiffer{
release1: r1,
release2: r2,
}
}
}
}
return
} | go | {
"resource": ""
} |
q182410 | StructName | test | func (v *Record) StructName(i int, packagename string, properties []string) (structname string) {
if i > 0 {
currentNode := v.Slice[i-1]
structname = FormatName(currentNode)
if i > 1 {
parentNames := v.FindAllParentsOfSameNamedElement(currentNode, properties)
if len(parentNames) > 1 {
structname = FormatName(v.Slice[i-2] + "_" + currentNode)
}
}
} else {
structname = FormatName(packagename + "_job")
}
return
} | go | {
"resource": ""
} |
q182411 | TypeName | test | func (v *Record) TypeName(i int, properties []string) (typename string) {
if i+1 < v.Length {
currentNode := v.Slice[i]
typename = "*" + FormatName(currentNode)
if i >= 1 {
parentNames := v.FindAllParentsOfSameNamedElement(currentNode, properties)
if len(parentNames) > 1 {
typename = "*" + FormatName(v.Slice[i-1]+"_"+currentNode)
}
}
} else {
typename = "interface{}"
}
return
} | go | {
"resource": ""
} |
q182412 | NewTgzWalker | test | func NewTgzWalker(pkgReader io.Reader) Walker {
return tgzWalker{
pkgReader: pkgReader,
callbacks: make(map[*regexp.Regexp]WalkFunc),
}
} | go | {
"resource": ""
} |
q182413 | NewBackoff | test | func NewBackoff(strategy BackoffStrategy, start time.Duration, limit time.Duration) *Backoff {
backoff := Backoff{strategy: strategy, start: start, limit: limit}
backoff.Reset()
return &backoff
} | go | {
"resource": ""
} |
q182414 | Reset | test | func (b *Backoff) Reset() {
b.count = 0
b.LastDuration = 0
b.NextDuration = b.getNextDuration()
} | go | {
"resource": ""
} |
q182415 | NewExponential | test | func NewExponential(start time.Duration, limit time.Duration) *Backoff {
return NewBackoff(exponential{}, start, limit)
} | go | {
"resource": ""
} |
q182416 | NewExponentialFullJitter | test | func NewExponentialFullJitter(start time.Duration, limit time.Duration) *Backoff {
return NewBackoff(exponentialFullJitter{limit: limit}, start, limit)
} | go | {
"resource": ""
} |
q182417 | NewLinear | test | func NewLinear(start time.Duration, limit time.Duration) *Backoff {
return NewBackoff(linear{}, start, limit)
} | go | {
"resource": ""
} |
q182418 | GetLineSize | test | func (s *Sapin) GetLineSize(floor, line int) int {
return 1 + line*2 + floor*4 + int(floor/2*2)*int((floor+1)/2)
} | go | {
"resource": ""
} |
q182419 | GetMaxSize | test | func (s *Sapin) GetMaxSize() int {
return s.GetLineSize(s.Size-1, s.Size+3)
} | go | {
"resource": ""
} |
q182420 | compute | test | func (s *Sapin) compute() {
if s.output != "" {
return
}
// size of the last line of the last floor
maxSize := s.GetMaxSize()
// each floor in the floors
for floor := 0; floor < s.Size; floor++ {
// each line in the lines of the floor
for line := 0; line < floor+4; line++ {
// size of the current line
lineSize := s.GetLineSize(floor, line)
// pad left with spaces
for i := (maxSize-lineSize)/2 - 1; i > 0; i-- {
s.putchar(" ")
}
// draw the body
for i := 0; i < lineSize; i++ {
s.putchar("*")
}
// new line
s.putchar("\n")
}
}
// the trunc
for i := 0; i < s.Size; i++ {
lineSize := s.Size + (s.Size+1)%2
// pad left with spaces
for i := (maxSize-lineSize)/2 - 1; i > 0; i-- {
s.putchar(" ")
}
// draw the body
for i := 0; i < lineSize; i++ {
s.putchar("|")
}
// new line
s.putchar("\n")
}
} | go | {
"resource": ""
} |
q182421 | WithTimeout | test | func (o *PostAppsParams) WithTimeout(timeout time.Duration) *PostAppsParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182422 | WithContext | test | func (o *PostAppsParams) WithContext(ctx context.Context) *PostAppsParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182423 | WithHTTPClient | test | func (o *PostAppsParams) WithHTTPClient(client *http.Client) *PostAppsParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182424 | WithBody | test | func (o *PostAppsParams) WithBody(body *models.AppWrapper) *PostAppsParams {
o.SetBody(body)
return o
} | go | {
"resource": ""
} |
q182425 | WithTimeout | test | func (o *GetAppsAppParams) WithTimeout(timeout time.Duration) *GetAppsAppParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182426 | WithContext | test | func (o *GetAppsAppParams) WithContext(ctx context.Context) *GetAppsAppParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182427 | WithHTTPClient | test | func (o *GetAppsAppParams) WithHTTPClient(client *http.Client) *GetAppsAppParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182428 | WithApp | test | func (o *GetAppsAppParams) WithApp(app string) *GetAppsAppParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182429 | UnmarshalBinary | test | func (m *RouteWrapper) UnmarshalBinary(b []byte) error {
var res RouteWrapper
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
} | go | {
"resource": ""
} |
q182430 | WithTimeout | test | func (o *GetAppsParams) WithTimeout(timeout time.Duration) *GetAppsParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182431 | WithContext | test | func (o *GetAppsParams) WithContext(ctx context.Context) *GetAppsParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182432 | WithHTTPClient | test | func (o *GetAppsParams) WithHTTPClient(client *http.Client) *GetAppsParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182433 | WithTimeout | test | func (o *DeleteAppsAppParams) WithTimeout(timeout time.Duration) *DeleteAppsAppParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182434 | WithContext | test | func (o *DeleteAppsAppParams) WithContext(ctx context.Context) *DeleteAppsAppParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182435 | WithHTTPClient | test | func (o *DeleteAppsAppParams) WithHTTPClient(client *http.Client) *DeleteAppsAppParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182436 | WithApp | test | func (o *DeleteAppsAppParams) WithApp(app string) *DeleteAppsAppParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182437 | WithTimeout | test | func (o *PatchAppsAppRoutesRouteParams) WithTimeout(timeout time.Duration) *PatchAppsAppRoutesRouteParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182438 | WithContext | test | func (o *PatchAppsAppRoutesRouteParams) WithContext(ctx context.Context) *PatchAppsAppRoutesRouteParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182439 | WithHTTPClient | test | func (o *PatchAppsAppRoutesRouteParams) WithHTTPClient(client *http.Client) *PatchAppsAppRoutesRouteParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182440 | WithApp | test | func (o *PatchAppsAppRoutesRouteParams) WithApp(app string) *PatchAppsAppRoutesRouteParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182441 | WithBody | test | func (o *PatchAppsAppRoutesRouteParams) WithBody(body *models.RouteWrapper) *PatchAppsAppRoutesRouteParams {
o.SetBody(body)
return o
} | go | {
"resource": ""
} |
q182442 | WithRoute | test | func (o *PatchAppsAppRoutesRouteParams) WithRoute(route string) *PatchAppsAppRoutesRouteParams {
o.SetRoute(route)
return o
} | go | {
"resource": ""
} |
q182443 | WithTimeout | test | func (o *PostAppsAppRoutesParams) WithTimeout(timeout time.Duration) *PostAppsAppRoutesParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182444 | WithContext | test | func (o *PostAppsAppRoutesParams) WithContext(ctx context.Context) *PostAppsAppRoutesParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182445 | WithHTTPClient | test | func (o *PostAppsAppRoutesParams) WithHTTPClient(client *http.Client) *PostAppsAppRoutesParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182446 | WithApp | test | func (o *PostAppsAppRoutesParams) WithApp(app string) *PostAppsAppRoutesParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182447 | WithBody | test | func (o *PostAppsAppRoutesParams) WithBody(body *models.RouteWrapper) *PostAppsAppRoutesParams {
o.SetBody(body)
return o
} | go | {
"resource": ""
} |
q182448 | WithTimeout | test | func (o *PutAppsAppRoutesRouteParams) WithTimeout(timeout time.Duration) *PutAppsAppRoutesRouteParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182449 | WithContext | test | func (o *PutAppsAppRoutesRouteParams) WithContext(ctx context.Context) *PutAppsAppRoutesRouteParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182450 | WithApp | test | func (o *PutAppsAppRoutesRouteParams) WithApp(app string) *PutAppsAppRoutesRouteParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182451 | WithBody | test | func (o *PutAppsAppRoutesRouteParams) WithBody(body *models.RouteWrapper) *PutAppsAppRoutesRouteParams {
o.SetBody(body)
return o
} | go | {
"resource": ""
} |
q182452 | WithRoute | test | func (o *PutAppsAppRoutesRouteParams) WithRoute(route string) *PutAppsAppRoutesRouteParams {
o.SetRoute(route)
return o
} | go | {
"resource": ""
} |
q182453 | WithTimeout | test | func (o *GetAppsAppRoutesParams) WithTimeout(timeout time.Duration) *GetAppsAppRoutesParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182454 | WithContext | test | func (o *GetAppsAppRoutesParams) WithContext(ctx context.Context) *GetAppsAppRoutesParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182455 | WithHTTPClient | test | func (o *GetAppsAppRoutesParams) WithHTTPClient(client *http.Client) *GetAppsAppRoutesParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182456 | WithApp | test | func (o *GetAppsAppRoutesParams) WithApp(app string) *GetAppsAppRoutesParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182457 | WithTimeout | test | func (o *PatchAppsAppParams) WithTimeout(timeout time.Duration) *PatchAppsAppParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182458 | WithContext | test | func (o *PatchAppsAppParams) WithContext(ctx context.Context) *PatchAppsAppParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182459 | WithHTTPClient | test | func (o *PatchAppsAppParams) WithHTTPClient(client *http.Client) *PatchAppsAppParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182460 | WithApp | test | func (o *PatchAppsAppParams) WithApp(app string) *PatchAppsAppParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182461 | WithBody | test | func (o *PatchAppsAppParams) WithBody(body *models.AppWrapper) *PatchAppsAppParams {
o.SetBody(body)
return o
} | go | {
"resource": ""
} |
q182462 | WithTimeout | test | func (o *PutAppsAppParams) WithTimeout(timeout time.Duration) *PutAppsAppParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182463 | WithContext | test | func (o *PutAppsAppParams) WithContext(ctx context.Context) *PutAppsAppParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182464 | WithApp | test | func (o *PutAppsAppParams) WithApp(app string) *PutAppsAppParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182465 | WithBody | test | func (o *PutAppsAppParams) WithBody(body *models.AppWrapper) *PutAppsAppParams {
o.SetBody(body)
return o
} | go | {
"resource": ""
} |
q182466 | UnmarshalJSON | test | func (m *Task) UnmarshalJSON(raw []byte) error {
var aO0 NewTask
if err := swag.ReadJSON(raw, &aO0); err != nil {
return err
}
m.NewTask = aO0
var aO1 TaskAllOf1
if err := swag.ReadJSON(raw, &aO1); err != nil {
return err
}
m.TaskAllOf1 = aO1
return nil
} | go | {
"resource": ""
} |
q182467 | MarshalJSON | test | func (m Task) MarshalJSON() ([]byte, error) {
var _parts [][]byte
aO0, err := swag.WriteJSON(m.NewTask)
if err != nil {
return nil, err
}
_parts = append(_parts, aO0)
aO1, err := swag.WriteJSON(m.TaskAllOf1)
if err != nil {
return nil, err
}
_parts = append(_parts, aO1)
return swag.ConcatJSON(_parts...), nil
} | go | {
"resource": ""
} |
q182468 | Validate | test | func (m *Task) Validate(formats strfmt.Registry) error {
var res []error
if err := m.NewTask.Validate(formats); err != nil {
res = append(res, err)
}
if err := m.TaskAllOf1.Validate(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
} | go | {
"resource": ""
} |
q182469 | GetRanges | test | func GetRanges(ips []string, ip4_cidr string, ip6_cidr string) ([]net.IPNet, error) {
net_out := make([]net.IPNet, 0)
for _, ip := range ips {
cidr := ""
if strings.Contains(ip, ":") {
// IPv6
cidr = ip6_cidr
if cidr == "" {
cidr = "128"
}
if c, err := strconv.ParseInt(cidr, 10, 16); err != nil || c < 0 || c > 128 {
return nil, &PermError{"Invalid IPv6 CIDR length: " + cidr}
}
} else {
// IPv4
cidr = ip4_cidr
if cidr == "" {
cidr = "32"
}
if c, err := strconv.ParseInt(cidr, 10, 16); err != nil || c < 0 || c > 32 {
return nil, &PermError{"Invalid IPv4 CIDR length: " + cidr}
}
}
ip += "/" + cidr
_, ipnet, err := net.ParseCIDR(ip)
if err != nil {
return nil, err
}
net_out = append(net_out, *ipnet)
}
return net_out, nil
} | go | {
"resource": ""
} |
q182470 | WithTimeout | test | func (o *GetAppsAppRoutesRouteParams) WithTimeout(timeout time.Duration) *GetAppsAppRoutesRouteParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182471 | WithContext | test | func (o *GetAppsAppRoutesRouteParams) WithContext(ctx context.Context) *GetAppsAppRoutesRouteParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182472 | WithHTTPClient | test | func (o *GetAppsAppRoutesRouteParams) WithHTTPClient(client *http.Client) *GetAppsAppRoutesRouteParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182473 | WithApp | test | func (o *GetAppsAppRoutesRouteParams) WithApp(app string) *GetAppsAppRoutesRouteParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182474 | WithRoute | test | func (o *GetAppsAppRoutesRouteParams) WithRoute(route string) *GetAppsAppRoutesRouteParams {
o.SetRoute(route)
return o
} | go | {
"resource": ""
} |
q182475 | New | test | func New(transport runtime.ClientTransport, formats strfmt.Registry) *Functions {
cli := new(Functions)
cli.Transport = transport
cli.Apps = apps.New(transport, formats)
cli.Routes = routes.New(transport, formats)
cli.Tasks = tasks.New(transport, formats)
cli.Version = version.New(transport, formats)
return cli
} | go | {
"resource": ""
} |
q182476 | SetTransport | test | func (c *Functions) SetTransport(transport runtime.ClientTransport) {
c.Transport = transport
c.Apps.SetTransport(transport)
c.Routes.SetTransport(transport)
c.Tasks.SetTransport(transport)
c.Version.SetTransport(transport)
} | go | {
"resource": ""
} |
q182477 | WithTimeout | test | func (o *DeleteAppsAppRoutesRouteParams) WithTimeout(timeout time.Duration) *DeleteAppsAppRoutesRouteParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182478 | WithContext | test | func (o *DeleteAppsAppRoutesRouteParams) WithContext(ctx context.Context) *DeleteAppsAppRoutesRouteParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182479 | WithHTTPClient | test | func (o *DeleteAppsAppRoutesRouteParams) WithHTTPClient(client *http.Client) *DeleteAppsAppRoutesRouteParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182480 | WithApp | test | func (o *DeleteAppsAppRoutesRouteParams) WithApp(app string) *DeleteAppsAppRoutesRouteParams {
o.SetApp(app)
return o
} | go | {
"resource": ""
} |
q182481 | WithRoute | test | func (o *DeleteAppsAppRoutesRouteParams) WithRoute(route string) *DeleteAppsAppRoutesRouteParams {
o.SetRoute(route)
return o
} | go | {
"resource": ""
} |
q182482 | WithTimeout | test | func (o *GetTasksParams) WithTimeout(timeout time.Duration) *GetTasksParams {
o.SetTimeout(timeout)
return o
} | go | {
"resource": ""
} |
q182483 | WithContext | test | func (o *GetTasksParams) WithContext(ctx context.Context) *GetTasksParams {
o.SetContext(ctx)
return o
} | go | {
"resource": ""
} |
q182484 | WithHTTPClient | test | func (o *GetTasksParams) WithHTTPClient(client *http.Client) *GetTasksParams {
o.SetHTTPClient(client)
return o
} | go | {
"resource": ""
} |
q182485 | NewValueStore | test | func NewValueStore(addr string, concurrency int, ftlsConfig *ftls.Config, opts ...grpc.DialOption) (store.ValueStore, error) {
stor := &valueStore{
addr: addr,
ftlsc: ftlsConfig,
opts: opts,
handlersDoneChan: make(chan struct{}),
}
stor.pendingLookupReqChan = make(chan *asyncValueLookupRequest, concurrency)
stor.freeLookupReqChan = make(chan *asyncValueLookupRequest, concurrency)
stor.freeLookupResChan = make(chan *asyncValueLookupResponse, concurrency)
for i := 0; i < cap(stor.freeLookupReqChan); i++ {
stor.freeLookupReqChan <- &asyncValueLookupRequest{resChan: make(chan *asyncValueLookupResponse, 1)}
}
for i := 0; i < cap(stor.freeLookupResChan); i++ {
stor.freeLookupResChan <- &asyncValueLookupResponse{}
}
go stor.handleLookupStream()
stor.pendingReadReqChan = make(chan *asyncValueReadRequest, concurrency)
stor.freeReadReqChan = make(chan *asyncValueReadRequest, concurrency)
stor.freeReadResChan = make(chan *asyncValueReadResponse, concurrency)
for i := 0; i < cap(stor.freeReadReqChan); i++ {
stor.freeReadReqChan <- &asyncValueReadRequest{resChan: make(chan *asyncValueReadResponse, 1)}
}
for i := 0; i < cap(stor.freeReadResChan); i++ {
stor.freeReadResChan <- &asyncValueReadResponse{}
}
go stor.handleReadStream()
stor.pendingWriteReqChan = make(chan *asyncValueWriteRequest, concurrency)
stor.freeWriteReqChan = make(chan *asyncValueWriteRequest, concurrency)
stor.freeWriteResChan = make(chan *asyncValueWriteResponse, concurrency)
for i := 0; i < cap(stor.freeWriteReqChan); i++ {
stor.freeWriteReqChan <- &asyncValueWriteRequest{resChan: make(chan *asyncValueWriteResponse, 1)}
}
for i := 0; i < cap(stor.freeWriteResChan); i++ {
stor.freeWriteResChan <- &asyncValueWriteResponse{}
}
go stor.handleWriteStream()
stor.pendingDeleteReqChan = make(chan *asyncValueDeleteRequest, concurrency)
stor.freeDeleteReqChan = make(chan *asyncValueDeleteRequest, concurrency)
stor.freeDeleteResChan = make(chan *asyncValueDeleteResponse, concurrency)
for i := 0; i < cap(stor.freeDeleteReqChan); i++ {
stor.freeDeleteReqChan <- &asyncValueDeleteRequest{resChan: make(chan *asyncValueDeleteResponse, 1)}
}
for i := 0; i < cap(stor.freeDeleteResChan); i++ {
stor.freeDeleteResChan <- &asyncValueDeleteResponse{}
}
go stor.handleDeleteStream()
return stor, nil
} | go | {
"resource": ""
} |
q182486 | Close | test | func (stor *valueStore) Close() {
stor.lock.Lock()
stor.shutdown()
close(stor.handlersDoneChan)
stor.lock.Unlock()
} | go | {
"resource": ""
} |
q182487 | SetBackend | test | func (o *Server) SetBackend(backend OortService) {
o.Lock()
o.backend = backend
o.Unlock()
} | go | {
"resource": ""
} |
q182488 | Ring | test | func (o *Server) Ring() ring.Ring {
o.RLock()
defer o.RUnlock()
return o.ring
} | go | {
"resource": ""
} |
q182489 | GetLocalID | test | func (o *Server) GetLocalID() uint64 {
o.RLock()
defer o.RUnlock()
return o.localID
} | go | {
"resource": ""
} |
q182490 | GetListenAddr | test | func (o *Server) GetListenAddr() string {
o.RLock()
defer o.RUnlock()
return o.ring.LocalNode().Address(2)
} | go | {
"resource": ""
} |
q182491 | Startup | test | func (rs *ReplGroupStore) Startup(ctx context.Context) error {
rs.ringLock.Lock()
if rs.ringServerExitChan == nil {
rs.ringServerExitChan = make(chan struct{})
go rs.ringServerConnector(rs.ringServerExitChan)
}
rs.ringLock.Unlock()
return nil
} | go | {
"resource": ""
} |
q182492 | shutdownFinished | test | func (o *Server) shutdownFinished() {
time.Sleep(10 * time.Millisecond)
close(o.ShutdownComplete)
} | go | {
"resource": ""
} |
q182493 | Stop | test | func (o *Server) Stop() error {
o.cmdCtrlLock.Lock()
defer o.cmdCtrlLock.Unlock()
if o.stopped {
return fmt.Errorf("Service already stopped")
}
close(o.ch)
o.backend.StopListenAndServe()
o.backend.Wait()
o.backend.Stop()
o.stopped = true
return nil
} | go | {
"resource": ""
} |
q182494 | Exit | test | func (o *Server) Exit() error {
o.cmdCtrlLock.Lock()
defer o.cmdCtrlLock.Unlock()
if o.stopped {
o.backend.Stop()
defer o.shutdownFinished()
return nil
}
close(o.ch)
o.backend.StopListenAndServe()
o.backend.Wait()
o.backend.Stop()
o.stopped = true
defer o.shutdownFinished()
return nil
} | go | {
"resource": ""
} |
q182495 | SelfUpgrade | test | func (o *Server) SelfUpgrade(version string, bindiff, checksum []byte) (bool, string) {
o.cmdCtrlLock.Lock()
defer o.cmdCtrlLock.Unlock()
err := o.binaryUpgrade.Upgrade(version)
if err != nil {
return false, err.Error()
}
return true, ""
} | go | {
"resource": ""
} |
q182496 | SoftwareVersion | test | func (o *Server) SoftwareVersion() string {
o.cmdCtrlLock.RLock()
defer o.cmdCtrlLock.RUnlock()
return o.binaryUpgrade.GetCurrentVersion()
} | go | {
"resource": ""
} |
q182497 | Shutdown | test | func (stor *groupStore) Shutdown(ctx context.Context) error {
stor.lock.Lock()
err := stor.shutdown()
stor.lock.Unlock()
return err
} | go | {
"resource": ""
} |
q182498 | Rant | test | func (c *Client) Rant(rantId int) (RantModel, []CommentModel, error) {
url := fmt.Sprintf(RANT_PATH, API, rantId, APP_VERSION)
res, err := http.Get(url)
if err != nil {
return RantModel{}, nil, err
}
var data RantResponse
json.NewDecoder(res.Body).Decode(&data)
if !data.Success && data.Error != "" {
return RantModel{}, nil, errors.New(data.Error)
}
return data.Rant, data.Comments, nil
} | go | {
"resource": ""
} |
q182499 | Profile | test | func (c *Client) Profile(username string) (UserModel, ContentModel, error) {
userId, err := getUserId(username)
if err != nil {
return UserModel{}, ContentModel{}, err
}
url := fmt.Sprintf(USER_PATH, API, userId, APP_VERSION)
res, err := http.Get(url)
if err != nil {
return UserModel{}, ContentModel{}, err
}
var data UserResponse
json.NewDecoder(res.Body).Decode(&data)
if !data.Success && data.Error != "" {
return UserModel{}, ContentModel{}, errors.New(data.Error)
}
return data.Profile, data.Profile.Content.Content, nil
} | go | {
"resource": ""
} |