id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c9800
return nil, err } defer f.Close() return ReadMIME(f) }
c9801
query} if err := req.Prepare(); err != nil { return nil, err } return req, nil }
c9802
return err } } return req.Adapter().Prepare(req) }
c9803
nil, err } return DefaultClient.Fetch(req) }
c9804
fmt.Errorf("no public zone found for %s", query) } host := z.WhoisServer() wu := z.WhoisURL() if host != "" { return host, wu, nil } u, err := url.Parse(wu) if err == nil && u.Host != "" { return u.Host, wu, nil } return "", "", fmt.Errorf("no whois server found for %s", query) }
c9805
c.FetchContext(context.Background(), req) }
c9806
defer cancel() } if req.URL != "" { return c.fetchHTTP(ctx, req) } return c.fetchWhois(ctx, req) }
c9807
copy(scopes, l) return scopes }
c9808
for i, s := range scopes { if s == scope { return scopes[:i] } } return ScopeList{} }
c9809
scope == s { return true } } return false }
c9810
defs[name] = def } return defs }
c9811
l == nil { return builtList{name: 0} } l[name] = len(l) return l }
c9812
ok := l[name] return ok }
c9813
len(l)) for name, i := range l { s[i] = name } return s }
c9814
b.errs = append(b.errs, err) } }
c9815
b.errs { msgs[i] = err.Error() } return errors.New(strings.Join(msgs, " AND ")) }
c9816
err = fmt.Errorf("the fill destination should be a pointer to a `%s`, but you used a `%s`", s, d) } }() reflect.ValueOf(dest).Elem().Set(reflect.ValueOf(src)) return err }
c9817
ok := b.definitions[name] return ok }
c9818
err != nil { return err } } return nil }
c9819
b.scopes[0], definitions: defs, parent: nil, children: map[*containerCore]struct{}{}, objects: map[string]interface{}{}, }, } }
c9820
logFunc(err.Error()) } }() // call the handler with a new request // containing the container in its context h(w, r.WithContext( context.WithValue(r.Context(), ContainerKey("di"), ctn), )) } }
c9821
} return errors.Wrap(fillValue(b, footer), "failed to decode footer") } if len(parts) < 3 { return ErrIncorrectTokenFormat } return nil }
c9822
!= audience { return errors.Wrapf(ErrTokenValidationError, `token was not intended for "%s" audience`, audience) } return nil } }
c9823
!= jti { return errors.Wrapf(ErrTokenValidationError, `token was expected to be identified by "%s"`, jti) } return nil } }
c9824
!= issuer { return errors.Wrapf(ErrTokenValidationError, `token was not issued by "%s"`, issuer) } return nil } }
c9825
!= subject { return errors.Wrapf(ErrTokenValidationError, `token was not related to subject "%s"`, subject) } return nil } }
c9826
be used yet") } if !token.Expiration.IsZero() && t.After(token.Expiration) { return errors.Wrapf(ErrTokenValidationError, "token has expired") } return nil } }
c9827
footer to []byte") } sig := ed25519.Sign(key, preAuthEncode(headerV2Public, payloadBytes, footerBytes)) return createToken(headerV2Public, append(payloadBytes, sig...), footerBytes), nil }
c9828
size") } payloadBytes := data[:len(data)-v2SignSize] signature := data[len(data)-v2SignSize:] if !ed25519.Verify(pub, preAuthEncode(headerV2Public, payloadBytes, footerBytes), signature) { return ErrInvalidSignature } if payload != nil { if err := fillValue(payloadBytes, payload); err != nil { return e...
c9829
t.claims == nil { t.claims = make(map[string]string) } t.claims[key] = value }
c9830
if !t.Expiration.IsZero() { t.claims["exp"] = t.Expiration.Format(time.RFC3339) } if !t.IssuedAt.IsZero() { t.claims["iat"] = t.IssuedAt.Format(time.RFC3339) } if !t.NotBefore.IsZero() { t.claims["nbf"] = t.NotBefore.Format(time.RFC3339) } return json.Marshal(t.claims) }
c9831
function chaining") return j } rj.done = true return j }
c9832
case <-j.Quit: return case <-j.SkipWait: go runJob(j) case <-time.After(next): go runJob(j) } next, _ = j.schedule.nextRun() } }(j) return j, nil }
c9833
= errors.New("bad function chaining") } j.schedule = daily{} return j }
c9834
msg: NewMessage(MSG_INFO, []byte(commandStr)), } if err := newInfo.sendCommand(conn); err != nil { return nil, err } return newInfo, nil }
c9835
err != nil { return nil, err } return info.parseMultiResponse() }
c9836
// Logger.Debug("Header Response: %v %v %v %v", t.Type, t.Version, t.Length(), t.DataLen) if err := nfo.msg.Resize(nfo.msg.Length()); err != nil { return err } _, err := conn.Read(nfo.msg.Data, len(nfo.msg.Data)) return err }
c9837
&Host{Name: name, Port: port} }
c9838
newCluster.user = policy.User hashedPass, err := hashPassword(policy.Password) if err != nil { return nil, err } newCluster.password = NewSyncVal(hashedPass) } // try to seed connections for first use err := newCluster.waitTillStabilized() // apply policy rules if policy.FailIfNotConnected && !newClu...
c9839
if tendDuration := time.Since(tm); tendDuration > clstr.clientPolicy.TendInterval { Logger.Warn("Tending took %s, while your requested ClientPolicy.TendInterval is %s. Tends are slower than the interval, and may be falling behind the changes in the cluster.", tendDuration, clstr.clientPolicy.TendInterval) } }...
c9840
(interface{}, error) { seeds := val.([]*Host) seeds = append(seeds, hosts...) return seeds, nil }) }
c9841
} time.Sleep(time.Millisecond) count = len(clstr.GetNodes()) } doneCh <- err }() select { case <-time.After(clstr.clientPolicy.Timeout): if clstr.clientPolicy.FailIfNotConnected { clstr.Close() } return errors.New("Connecting to the cluster timed out.") case err := <-doneCh: if err != nil ...
c9842
if err != nil { Logger.Warn("Seed %s failed: %s", seed.String(), err.Error()) errChan <- err return } clstr.addNodes(nodesToAdd) successChan <- struct{}{} }(i, seed) } errorList := make([]error, 0, len(seedArray)) seedCount := len(seedArray) L: for { select { case err := <-errChan: ...
c9843
if node.GetName() == name { return true } } return false }
c9844
found if seqNode == nil { seqNode = node } // if the node didn't belong to rack for that namespace, continue nodeRack, err := node.Rack(partition.Namespace) if err != nil { continue } if node.IsActive() && nodeRack == clstr.clientPolicy.RackId { return node, nil } } } // if n...
c9845
:= nodeArray[index] if node != nil && node.IsActive() { // Logger.Debug("Node `%s` is active. index=%d", node, index) return node, nil } } return nil, NewAerospikeError(INVALID_NODE_ERROR, "Cluster is empty.") }
c9846
:= range seeds { res = append(res, *seed) } return res, nil }) return res.([]Host) }
c9847
aliases := val.(map[Host]*Node) res := make(map[Host]*Node, len(aliases)) for h, n := range aliases { res[h] = n } return res, nil }) return res.(map[Host]*Node) }
c9848
return nil, NewAerospikeError(INVALID_NODE_ERROR, "Invalid node name"+nodeName) } return node, nil }
c9849
close signal to maintenance channel close(clstr.tendChannel) // wait until tend is over clstr.wgTend.Wait() } }
c9850
done <- true return } } } res, err = false, nil done <- false }() dealine := time.After(timeout) for { select { case <-dealine: return false, NewAerospikeError(TIMEOUT) case <-done: return res, err } } }
c9851
<- err return } } }() dealine := time.After(timeout) select { case <-dealine: return NewAerospikeError(TIMEOUT) case err = <-done: return err } }
c9852
!= nil { return pass.([]byte) } return nil }
c9853
L.SetField(mt, "log", L.NewFunction(luaAerospikeLog)) L.SetMetatable(mt, mt) }
c9854
{ return &IndexTask{ baseTask: newTask(cluster), namespace: namespace, indexName: indexName, } }
c9855
= 0 } else if bc.len() > 0 { copy(bc.buf(), bc.buf()[bc.head:bc.tail]) bc.tail -= bc.head bc.head = 0 } else { bc.tail = 0 bc.head = 0 } }
c9856
bc.conn.Read(bc.buf()[bc.tail:], toRead) bc.tail += n bc.remaining -= n if err != nil { return fmt.Errorf("Requested to read %d bytes, but %d was read. (%v)", minLength, n, err) } return nil }
c9857
NewAtomicBool(true), closed: NewAtomicBool(false), goroutines: NewAtomicInt(goroutines), cancelled: make(chan struct{}), taskID: taskID, } rs.wgGoroutines.Add(goroutines) return rs }
c9858
objectset: *newObjectset(reflect.ValueOf(nilChan), goroutines, taskID), } runtime.SetFinalizer(rs, recordsetFinalizer) return rs }
c9859
we should listen // to other chans again to determine either cancellation, // or normal EOR goto L } } return record, err }
c9860
the recordset as inactive rcs.active.Set(false) close(rcs.cancelled) // wait till all goroutines are done, and signalEnd is called by the scan command rcs.wgGoroutines.Wait() return nil }
c9861
return NewClientWithPolicyAndHost(policy, NewHost(hostname, port)) }
c9862
cluster, DefaultPolicy: NewPolicy(), DefaultBatchPolicy: NewBatchPolicy(), DefaultWritePolicy: NewWritePolicy(0, 0), DefaultScanPolicy: NewScanPolicy(), DefaultQueryPolicy: NewQueryPolicy(), DefaultAdminPolicy: NewAdminPolicy(), } runtime.SetFinalizer(client, clientFinalizer) return cl...
c9863
:= range nodes { names = append(names, node.GetName()) } return names }
c9864
newWriteCommand(clnt.cluster, policy, key, bins, nil, _APPEND) return command.Execute() }
c9865
:= newWriteCommand(clnt.cluster, policy, key, bins, nil, _PREPEND) return command.Execute() }
c9866
newWriteCommand(clnt.cluster, policy, key, bins, nil, _ADD) return command.Execute() }
c9867
it will be cloned and prepared cmd := newBatchCommandExists(nil, nil, nil, policy, keys, existsArray) if err := clnt.batchExecute(policy, keys, cmd); err != nil { return nil, err } return existsArray, nil }
c9868
err := command.Execute(); err != nil { return nil, err } return command.GetRecord(), nil }
c9869
nil, policy, keys, nil, records, _INFO1_READ|_INFO1_NOBINDATA) err := clnt.batchExecute(policy, keys, cmd) if err != nil && !policy.AllowPartialResults { return nil, err } return records, err }
c9870
// results channel must be async for performance taskID := uint64(xornd.Int64()) res := newRecordset(policy.RecordQueueSize, 1, taskID) go clnt.scanNode(&policy, node, res, namespace, setName, taskID, binNames...) return res, nil }
c9871
strCmd.WriteString(";udf-type=") _, err = strCmd.WriteString(string(language)) _, err = strCmd.WriteString(";") // Send UDF to one node. That node will distribute the UDF to other nodes. responseMap, err := clnt.sendInfoCommand(policy.TotalTimeout, strCmd.String()) if err != nil { return nil, err } response...
c9872
err = strCmd.WriteString(udfName) _, err = strCmd.WriteString(";") // Send command to one node. That node will distribute it to other nodes. responseMap, err := clnt.sendInfoCommand(policy.TotalTimeout, strCmd.String()) if err != nil { return nil, err } response := responseMap[strCmd.String()] if response =...
c9873
return nil, err } response := responseMap[strCmd.String()] vals := strings.Split(response, ";") res := make([]*UDF, 0, len(vals)) for _, udfInfo := range vals { if strings.Trim(udfInfo, " ") == "" { continue } udfParts := strings.Split(udfInfo, ",") udf := &UDF{} for _, values := range udfParts { ...
c9874
} statement.SetAggregateFunction(packageName, functionName, functionArgs, false) command := newServerCommand(node, policy, statement) err := command.Execute() return NewExecuteTask(clnt.cluster, statement), err }
c9875
:= *policy command := newQueryRecordCommand(node, &newPolicy, statement, recSet) go func() { command.Execute() }() return recSet, nil }
c9876
return clnt.CreateComplexIndex(policy, namespace, setName, indexName, binName, indexType, ICT_DEFAULT) }
c9877
response := responseMap[strCmd.String()] if strings.ToUpper(response) == "OK" { // Return task that could optionally be polled for completion. task := NewDropIndexTask(clnt.cluster, namespace, indexName) return <-task.OnComplete() } if strings.HasPrefix(response, "FAIL:201") { // Index did not previousl...
c9878
newAdminCommand(nil) return command.dropUser(clnt.cluster, policy, user) }
c9879
} } else { // Change other user's password by user admin. if err := command.setPassword(clnt.cluster, policy, user, hash); err != nil { return err } } clnt.cluster.changePassword(user, password, hash) return nil }
c9880
command := newAdminCommand(nil) return command.grantRoles(clnt.cluster, policy, user, roles) }
c9881
command := newAdminCommand(nil) return command.revokeRoles(clnt.cluster, policy, user, roles) }
c9882
command := newAdminCommand(nil) return command.queryUser(clnt.cluster, policy, user) }
c9883
command := newAdminCommand(nil) return command.queryUsers(clnt.cluster, policy) }
c9884
command := newAdminCommand(nil) return command.queryRole(clnt.cluster, policy, role) }
c9885
:= newAdminCommand(nil) return command.queryRoles(clnt.cluster, policy) }
c9886
policy = clnt.getUsableAdminPolicy(policy) command := newAdminCommand(nil) return command.createRole(clnt.cluster, policy, roleName, privileges) }
c9887
:= newAdminCommand(nil) return command.dropRole(clnt.cluster, policy, roleName) }
c9888
policy = clnt.getUsableAdminPolicy(policy) command := newAdminCommand(nil) return command.grantPrivileges(clnt.cluster, policy, roleName, privileges) }
c9889
return command.revokePrivileges(clnt.cluster, policy, roleName, privileges) }
c9890
return clnt.cluster.String() } return "" }
c9891
err } res := map[string]interface{}{} err = json.Unmarshal(b, &res) if err != nil { return nil, err } res["open-connections"] = clusterStats.ConnectionsOpen return res, nil }
c9892
nil { return "", err } return base64.StdEncoding.EncodeToString(b), nil }
c9893
time.Now().Unix() expiration := int64(CITRUSLEAF_EPOCH + secsFromCitrusLeafEpoc) if expiration < 0 || expiration > now { return uint32(expiration - now) } return 1 } }
c9894
fmt.Sprintf("%02x ", buf[i]) idx := i * 3 copy(hlist[idx:], hex) } return string(hlist) }
c9895
if l > uint32sz { l = uint32sz } r := int32(binary.LittleEndian.Uint32(buf[offset : offset+l])) return r }
c9896
if l > uint64sz { l = uint64sz } r := int64(binary.BigEndian.Uint64(buf[offset : offset+l])) return r }
c9897
int32(binary.BigEndian.Uint32(buf[offset : offset+uint32sz])) }
c9898
{ return binary.BigEndian.Uint32(buf[offset : offset+uint32sz]) }
c9899
int16(binary.BigEndian.Uint16(buf[offset : offset+uint16sz])) }