text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func New(key string) (*Database, error) {
db := &Database{ctx: context.Background()}
// We use a service account. The key location defaults to "./fbkey.json", but can be configured by the "-f" flag
opt := option.WithCredentialsFile(key)
app, err := firebase.NewApp(db.ctx, nil, opt)
if err != nil {
return nil, e... | [
0.018679585307836533,
-0.05335131660103798,
0.3468390703201294,
0.31492912769317627,
-0.8566147685050964,
0.2522006928920746,
-0.30847370624542236,
0.07233937084674835,
-0.38274309039115906,
0.02268090844154358,
-0.3868931233882904,
0.06106071174144745,
-0.2225579172372818,
1.1589339971542... |
func (db *Database) CreateUser(user *models.User) error {
_, err := db.Collection(userCol).Doc(user.ID).Create(db.ctx, user)
if err != nil && status.Code(err) != codes.AlreadyExists {
return err
}
return nil
} | [
-0.5934638381004333,
0.5391079783439636,
0.2814427614212036,
0.504546046257019,
1.2422274351119995,
1.0843509435653687,
0.6032076478004456,
-0.7140769362449646,
0.05765845999121666,
-0.022448986768722534,
-0.7916377186775208,
-0.8680300116539001,
-0.3072652518749237,
0.7853013277053833,
... |
func (db *Database) GetUserByID(id string) (*models.User, error) {
doc, err := db.Collection(userCol).Doc(id).Get(db.ctx)
if err != nil {
if status.Code(err) == codes.NotFound {
return nil, models.ErrNotFound
}
return nil, err
}
data := doc.Data()
var user models.User
err = mapstructure.Decode(data, ... | [
-0.18176032602787018,
-0.027074789628386497,
0.05210496112704277,
0.15730348229408264,
0.17191505432128906,
0.31241026520729065,
0.18013325333595276,
-0.9999666810035706,
0.0877152532339096,
0.48844093084335327,
-0.823485255241394,
-0.27510273456573486,
-0.38401079177856445,
0.157512262463... |
func (db *Database) GetUserByName(name string) (*models.User, error) {
docs, err := db.Collection(userCol).Where("name", "==", name).Where("public", "==", true).Documents(db.ctx).GetAll()
if err != nil {
if status.Code(err) != codes.NotFound {
return nil, models.ErrNotFound
}
return nil, err
}
// checkin... | [
-0.256357878446579,
0.22655995190143585,
0.5747421383857727,
0.33689820766448975,
0.16943250596523285,
0.0371757373213768,
0.2835676968097687,
-0.6777663826942444,
-0.2535313665866852,
0.5445113778114319,
-0.5492162704467773,
-0.3850807845592499,
-0.9106091260910034,
0.20170599222183228,
... |
func (db *Database) UpdateUser(user *models.User) error {
user.Name = "" // username and games are updated by dedicated functions
user.Games = nil
s := structs.New(user)
m := make(map[string]interface{})
for _, f := range s.Fields() {
if !f.IsZero() {
m[f.Tag("firestore")] = f.Value()
}
}
_, err := db.... | [
-1.2888253927230835,
0.21508102118968964,
0.6271281242370605,
0.20785729587078094,
-0.30338987708091736,
0.644662618637085,
0.8770063519477844,
-0.023136068135499954,
-0.14497536420822144,
-0.2355874627828598,
-0.9640598297119141,
-1.0131902694702148,
0.03286862373352051,
0.367905765771865... |
func (db *Database) UpdateGames(user *models.User) error {
// sorting the games, such that they are sorted when the user retrieves them
sort.Slice(user.Games, func(i, j int) bool {
return user.Games[i].Time > user.Games[j].Time
})
// calculating total game time
var totalGameTime int
for _, game := range user.G... | [
-0.8157414793968201,
0.3180992901325226,
0.7517284154891968,
-0.3760809898376465,
-0.300687700510025,
0.6959837079048157,
0.021250247955322266,
-0.5454755425453186,
-0.46487298607826233,
1.610958456993103,
0.06080104038119316,
-0.6381755471229553,
-0.4705072045326233,
0.07476527988910675,
... |
func (db *Database) SetUsername(user *models.User) error {
user.Name = strings.ToLower(user.Name)
dbUser, err := db.GetUserByName(user.Name)
if err != nil && !errors.Is(err, models.ErrNotFound) {
return err
}
if dbUser != nil {
if dbUser.Name == user.Name {
return nil
}
return errors.New("name already... | [
-0.8881649374961853,
0.30715861916542053,
0.638793408870697,
0.5380813479423523,
-0.7303376197814941,
-0.04621747508645058,
0.41890135407447815,
-0.21372470259666443,
0.0655650943517685,
0.6828140616416931,
-1.2770154476165771,
-0.6520698070526123,
-0.3021809458732605,
0.6943426132202148,
... |
func (db *Database) DeleteUser(id string) error {
_, err := db.Collection(userCol).Doc(id).Delete(db.ctx)
return err
} | [
-0.7659009099006653,
0.22886700928211212,
0.029225772246718407,
0.48013588786125183,
0.2506392002105713,
0.6099470257759094,
0.6129745841026306,
-0.15729713439941406,
0.08100331574678421,
-0.3515360355377197,
-0.915695309638977,
-0.3229845464229584,
-0.0823887512087822,
0.6771824359893799,... |
func (db *Database) IsUser(id string) (bool, error) {
_, err := db.Collection(userCol).Doc(id).Get(db.ctx)
if err != nil {
if status.Code(err) == codes.NotFound {
return false, nil
}
return false, err
}
return true, nil
} | [
-1.1340818405151367,
-0.10589085519313812,
0.6202021837234497,
0.5639586448669434,
0.4466559886932373,
0.4094150960445404,
0.198211669921875,
0.27201294898986816,
0.7303388714790344,
-0.08208725601434708,
-0.4541822075843811,
0.04975712299346924,
-0.6137579083442688,
0.5006489753723145,
... |
func (s *Server) CleanTableHandler(c echo.Context) error {
var tableName = c.Param("tablename")
go func() {
for {
n, err := sqlutils.TableDelRecordsBatch(s.DB, tableName, s.Cfg.TableRecordsLifeTimeDays, s.Cfg.TableRecordsDelBatchSize)
if err != nil {
logrus.Errorf("table %s delete records batch err: %s",... | [
-0.2889419198036194,
-0.1612100750207901,
0.8651798367500305,
0.162273108959198,
-0.8933615684509277,
-0.07359319180250168,
0.7875682711601257,
0.28411757946014404,
-0.0027181615587323904,
0.8529754877090454,
-0.5996619462966919,
-0.4171909987926483,
-0.2350778430700302,
0.7264212369918823... |
func runNFSFileE2ETest(helper *clients.TestClient, k8sh *utils.K8sHelper, s *suite.Suite, settings *installer.TestCephSettings, filesystemName string) {
defer fileTestDataCleanUp(helper, k8sh, s, filePodName, settings.Namespace, filesystemName)
logger.Infof("Running on Rook Cluster %s", settings.Namespace)
logger.In... | [
0.5575810670852661,
-0.4203169643878937,
0.7588303685188293,
-0.025930311530828476,
0.8313482999801636,
-0.24675270915031433,
0.6848353147506714,
-0.59740149974823,
-0.2782089114189148,
-0.026465080678462982,
-0.08435529470443726,
0.03839410841464996,
-0.9279465675354004,
0.397711038589477... |
func DecodeFile(path string) (*Pattern, error) {
// Open the file
f, ferr := os.Open(path)
defer f.Close()
if ferr != nil {
return decodeError("Error reading file: "+path, ferr)
}
// skip start of file
f.Seek(13, 0)
// check how much of the file we should read to avoid invalid file (see sample 5)
h, e := r... | [
0.3779160678386688,
-0.30853381752967834,
0.789546012878418,
-0.21026936173439026,
-0.3762834966182709,
0.13653050363063812,
0.35935431718826294,
1.0069209337234497,
-0.10912954807281494,
0.5343605279922485,
-0.806329607963562,
-0.08120376616716385,
-0.5985438823699951,
-0.595710277557373,... |
func readIntFromHex(data []byte) int {
x := hex.EncodeToString(data)
i, _ := strconv.Atoi(x)
return i
} | [
-0.2782406210899353,
-0.889008641242981,
0.3616248071193695,
-1.3364371061325073,
-0.4118877351284027,
0.4927433431148529,
-1.174971103668213,
0.7771648168563843,
-0.46036359667778015,
-0.07323376834392548,
-0.06325443089008331,
-0.8602718114852905,
-0.48209917545318604,
-0.041157010942697... |
func readNBytes(n int, f *os.File) ([]byte, error) {
bytesToRead := make([]byte, n)
_, e := f.Read(bytesToRead)
return bytesToRead, e
} | [
-0.691002368927002,
0.5424090027809143,
0.49031364917755127,
-0.5317849516868591,
-0.046256668865680695,
-0.1856614053249359,
-0.3833298981189728,
-0.10041964799165726,
-1.0350611209869385,
-0.17194639146327972,
-0.24830718338489532,
0.1228020191192627,
0.57863849401474,
0.3592096269130707... |
func readNBytesAsHex(n int, f *os.File) (string, error) {
bytes, e := readNBytes(n, f)
if e != nil {
return "", e
} else {
return hex.EncodeToString(bytes), nil
}
} | [
-0.18218062818050385,
0.02305050566792488,
0.44597989320755005,
-0.38873717188835144,
-0.02886437438428402,
0.0273137167096138,
-0.8303743004798889,
0.25190266966819763,
-0.18634632229804993,
-0.024438314139842987,
0.1638116091489792,
-0.858138382434845,
0.9914352297782898,
0.9837883114814... |
func NewRateCounter(intrvl time.Duration) *RateCounter {
return &RateCounter{
interval: intrvl,
}
} | [
0.1692766696214676,
-0.01519017294049263,
0.27068474888801575,
-0.4792724847793579,
-0.4564886689186096,
-0.007027425337582827,
-0.8011329174041748,
-0.9020190834999084,
0.12350092828273773,
-0.28740954399108887,
-0.5270146727561951,
1.193996787071228,
-0.713903546333313,
0.455072015523910... |
func (r *RateCounter) Incr(val int64) {
r.counter.Incr(val)
go r.scheduleDecrement(val)
} | [
0.512029767036438,
0.921312153339386,
0.25874465703964233,
0.28735464811325073,
-1.357704997062683,
1.0649408102035522,
0.4494369924068451,
0.06655817478895187,
0.5760995149612427,
-1.1106816530227661,
0.33807677030563354,
0.021224983036518097,
-0.3144335150718689,
1.141646146774292,
0.3... |
func (r *RateCounter) Rate() int64 {
return r.counter.Value()
} | [
-0.2641009986400604,
1.0752917528152466,
0.03764418885111809,
0.003882999299094081,
0.06624328345060349,
-0.2159385085105896,
-0.060474880039691925,
-0.16177794337272644,
0.09181533008813858,
-0.7023819088935852,
1.0086944103240967,
-0.4104244112968445,
-1.1295781135559082,
1.0862141847610... |
func (i StackFrame) MarshalText() ([]byte, error) {
if i.fn == nil {
return nil, ErrNoFunc
}
buf := bytes.Buffer{}
fmt.Fprint(&buf, i)
return buf.Bytes(), nil
} | [
0.8187976479530334,
0.4882380962371826,
0.40446820855140686,
0.4487564265727997,
-0.27299222350120544,
-0.5194991230964661,
-0.3994255065917969,
-0.1283564418554306,
0.35366326570510864,
0.17503100633621216,
-0.3341868221759796,
0.22163328528404236,
-0.8705275654792786,
0.02404041960835457... |
func (s Stack) MarshalText() ([]byte, error) {
buf := bytes.Buffer{}
buf.Write(openBracketBytes)
for i, item := range s {
if item.fn == nil {
return nil, ErrNoFunc
}
if i > 0 {
buf.Write(spaceBytes)
}
fmt.Fprint(&buf, item)
}
buf.Write(closeBracketBytes)
return buf.Bytes(), nil
} | [
0.36156409978866577,
0.4489024579524994,
0.7792041301727295,
0.17825689911842346,
-0.5266044735908508,
-0.8416692614555359,
-0.24560396373271942,
-0.357305109500885,
0.44721609354019165,
0.08498945087194443,
-0.34837445616722107,
0.09785754978656769,
-0.8322426676750183,
0.2848429381847381... |
func (s Stack) TrimBelow(item StackFrame) Stack {
for len(s) > 0 && s[0].pc != item.pc {
s = s[1:]
}
return s
} | [
1.2513774633407593,
-0.10700084269046783,
0.4943595826625824,
0.6865841150283813,
-0.026985174044966698,
0.8990898132324219,
0.41484445333480835,
-1.509814739227295,
0.5970050096511841,
0.6997097730636597,
-0.8499290943145752,
0.3295145034790039,
-1.5835320949554443,
-0.920770525932312,
... |
func (s Stack) TrimAbove(item StackFrame) Stack {
for len(s) > 0 && s[len(s)-1].pc != item.pc {
s = s[:len(s)-1]
}
return s
} | [
0.047026682645082474,
0.21657361090183258,
0.6842930912971497,
0.45590779185295105,
-0.058211203664541245,
0.4439674913883209,
0.3039880692958832,
-0.9168849587440491,
0.28114014863967896,
1.6322267055511475,
-0.82169508934021,
-0.33155858516693115,
-1.3819769620895386,
-1.1398550271987915... |
func pkgIndex(file, funcName string) int {
// As of Go 1.6.2 there is no direct way to know the compile time GOPATH
// at runtime, but we can infer the number of path segments in the GOPATH.
// We note that runtime.Func.Name() returns the function name qualified by
// the import path, which does not include the GOP... | [
-0.25907057523727417,
0.14862173795700073,
0.8729847073554993,
-0.278254896402359,
-0.3889070153236389,
-0.16916033625602722,
0.7242996692657471,
0.17970702052116394,
-0.6894168257713318,
-0.054131511598825455,
-0.35366329550743103,
-0.4152779281139374,
-0.26181021332740784,
-0.02492923289... |
func NewUsersManager(backend ablbind.ContractBackend) (UsersManager, error) {
contract, err := contracts.NewUsersContract(backend)
if err != nil {
return nil, err
}
return &usersManager{
UsersContract: contract,
client: backend,
log: logger.New("users"),
}, nil
} | [
-0.7915068864822388,
-0.8044052124023438,
0.04351770877838135,
-0.4755341708660126,
-0.6167529225349426,
-0.16619259119033813,
-0.7941539883613586,
-0.1519361138343811,
0.6231303215026855,
0.4136090874671936,
-0.43412312865257263,
0.2600202262401581,
-0.6063112020492554,
1.4399981498718262... |
func (manager *usersManager) Create(
ctx context.Context,
opts *ablbind.TransactOpts,
) (
[8]byte,
error,
) {
receipt, err := manager.UsersContract.Create(ctx, opts)
if err != nil {
return [8]byte{}, errors.Wrap(err, "failed to transact")
}
evt, err := manager.UsersContract.ParseSignedUpFromReceipt(receipt)
... | [
0.15147808194160461,
0.4397321045398712,
0.6055664420127869,
0.014527959749102592,
-0.4736116826534271,
0.1620032638311386,
0.08804478496313095,
-0.16008014976978302,
0.4146724343299866,
0.26385653018951416,
0.011544931679964066,
-0.5887885093688965,
-0.24632059037685394,
0.311557114124298... |
func (manager *usersManager) CreateTemporary(
ctx context.Context,
opts *ablbind.TransactOpts,
identityHash common.Hash,
) (
[8]byte,
error,
) {
receipt, err := manager.UsersContract.CreateTemporary(ctx, opts, identityHash)
if err != nil {
return [8]byte{}, errors.Wrap(err, "failed to transact")
}
evt, err ... | [
0.34026283025741577,
0.11426953971385956,
0.5735995173454285,
-0.2920907735824585,
-0.3604501485824585,
-0.27138492465019226,
-0.4041661024093628,
-0.42167744040489197,
0.6860954761505127,
0.29005441069602966,
-0.6161591410636902,
-0.6196213960647583,
-0.29367318749427795,
0.04792178422212... |
func (manager *usersManager) SetController(
ctx context.Context,
opts *ablbind.TransactOpts,
newController common.Address,
) error {
receipt, err := manager.UsersContract.SetController(ctx, opts, newController)
if err != nil {
return errors.Wrap(err, "failed to transact")
}
evt, err := manager.UsersContract.P... | [
0.12072747945785522,
-0.05017470568418503,
0.3236224353313446,
-0.4981086552143097,
-0.12321817874908447,
-0.2835914194583893,
0.20859892666339874,
0.37341809272766113,
0.7935161590576172,
0.35484400391578674,
-0.019297434017062187,
0.6135258078575134,
0.4705352187156677,
0.315741121768951... |
func (manager *usersManager) UnlockTemporary(
ctx context.Context,
opts *ablbind.TransactOpts,
identityPreimage common.Hash,
newOwner common.Address,
) error {
receipt, err := manager.UsersContract.UnlockTemporary(ctx, opts, identityPreimage, newOwner)
if err != nil {
return errors.Wrap(err, "failed to transact... | [
-0.17412380874156952,
0.07160556316375732,
0.3111374080181122,
-0.2398144155740738,
-0.663112223148346,
-0.6209778785705566,
0.34181830286979675,
0.07147976756095886,
0.015165461227297783,
0.8360698819160461,
-0.1835017055273056,
0.4951050579547882,
0.13816426694393158,
-0.634208083152771,... |
func (i *InstaBot) Manage(update tgbotapi.Update) {
var msg = update.Message.Text
switch msg {
case "/start":
i.CommandsHandler(update, msg, stateZERO)
case "/help":
i.CommandsHandler(update, msg, stateZERO)
case "/listunfollowers":
i.CommandsHandler(update, msg, stateLISTUNFOLLOWERS)
case "/subscribe":
i... | [
0.04511713236570358,
-0.42490869760513306,
0.34217190742492676,
0.5820963978767395,
0.4941951334476471,
0.2327870875597,
-0.2899499237537384,
0.007234477903693914,
0.11349263042211533,
-0.19525201618671417,
0.3674134314060211,
-0.18590913712978363,
-0.5296385884284973,
0.37762168049812317,... |
func (i *InstaBot) Handler(
update tgbotapi.Update,
msg string,
) {
//state, err := db.GetUserState(i.Box.Database.Conn, update.Message.Chat.ID)
// //if err != nil {
// // i.Box.TelegramBotAPI.Send(update.Message.Chat.ID, i.Answers["ERROR_user_does_not_exist"])
// // return
// //}
// //
// //switch state {
//... | [
-0.1817069947719574,
-0.3859019875526428,
0.8191272020339966,
0.38576310873031616,
-0.26815325021743774,
0.6180129051208496,
0.5485211610794067,
0.11112001538276672,
-0.15036524832248688,
-0.22773298621177673,
-0.4859943389892578,
-0.8235220313072205,
-0.0029192734509706497,
0.545385181903... |
func Init(workercount int) {
_ = fdlimit.Raise()
global = New(workercount)
} | [
0.7626045346260071,
0.9870086908340454,
0.3454605042934418,
-0.03304455801844597,
-0.16768188774585724,
0.7963676452636719,
0.6074387431144714,
0.4667682349681854,
-1.2914111614227295,
-0.5812588334083557,
-0.7804654836654663,
1.1096546649932861,
-0.8940495848655701,
0.8363466262817383,
... |
func Close() {
if global != nil {
global.Close()
}
} | [
0.6962270736694336,
0.6211715340614319,
0.4216698110103607,
0.23784546554088593,
-0.29537612199783325,
1.0577901601791382,
0.9905648231506348,
-0.08802084624767303,
-0.7260449528694153,
-0.05893351510167122,
0.7360073328018188,
0.6170910000801086,
-1.6965688467025757,
2.0140836238861084,
... |
func Run(task Task, waiter *Waiter) { global.Run(task, waiter) } | [
0.08118802309036255,
0.08790984004735947,
0.130480095744133,
1.4199578762054443,
-0.7304914593696594,
0.9834867119789124,
1.3172236680984497,
0.8922675251960754,
-0.9489926099777222,
0.1380758136510849,
-1.3333462476730347,
0.17352169752120972,
-0.15279223024845123,
1.0261211395263672,
-... |
func (rf *Raft) GetState() (int, bool) {
// Your code here (2A).
return rf.term, rf.state == RaftLeader
} | [
0.07981383055448532,
-0.11583665758371353,
0.5706232190132141,
0.8394838571548462,
-0.2320268452167511,
-0.43085262179374695,
0.4088800549507141,
-0.16926594078540802,
0.1712280958890915,
-0.14059121906757355,
-1.276543140411377,
1.079604983329773,
-0.8714113235473633,
0.5193517804145813,
... |
func (rf *Raft) persist() {
// Your code here (2C).
// Example:
w := new(bytes.Buffer)
e := labgob.NewEncoder(w)
e.Encode(rf.term)
e.Encode(rf.votedFor)
e.Encode(rf.logEntries)
data := w.Bytes()
rf.persister.SaveRaftState(data)
// DPrintf("%v persist term=%d voted-for=%d log-entries=%d", rf.raftInfo(), rf.te... | [
0.1881837248802185,
-0.10002054274082184,
0.5748111605644226,
-0.07469000667333603,
0.4656222462654114,
0.589262843132019,
0.14984005689620972,
-0.22561293840408325,
-0.09635615348815918,
-0.6914327144622803,
-1.0224310159683228,
0.06568163633346558,
-0.8467010259628296,
0.2050713449716568... |
func (rf *Raft) readPersist(data []byte) {
if data == nil || len(data) < 1 { // bootstrap without any state?
return
}
// Your code here (2C).
// Example:
r := bytes.NewBuffer(data)
d := labgob.NewDecoder(r)
if d.Decode(&rf.term) != nil {
panic("fail on read persist term")
}
if d.Decode(&rf.votedFor) != ... | [
0.09457457810640335,
-0.28257715702056885,
0.7016109824180603,
0.7836378812789917,
0.11371804773807526,
-0.11126483231782913,
-0.08897410333156586,
-0.025933347642421722,
0.026169894263148308,
-0.4725158214569092,
-0.03221863508224487,
0.1681782454252243,
-0.46251749992370605,
-0.025359177... |
func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {
// Your code here (2A, 2B).
ev := newRaftEV(args)
select {
case <-rf.quitc:
return
case rf.eventc <- ev:
}
<-ev.c
if ev.result == nil {
panic("unexpected nil result")
}
*reply = *(ev.result.(*RequestVoteReply))
} | [
-0.27946045994758606,
0.18471962213516235,
0.7852355241775513,
1.6334036588668823,
0.650591254234314,
-0.4776386618614197,
0.2446712851524353,
-0.5135049223899841,
-0.16053630411624908,
-0.31788358092308044,
0.15165595710277557,
0.7064899206161499,
-0.9526945352554321,
-0.04487888514995575... |
func (rf *Raft) sendRequestVote(server int, args *RequestVoteArgs, reply *RequestVoteReply) bool {
ok := rf.peers[server].Call("Raft.RequestVote", args, reply)
return ok
} | [
-1.7217257022857666,
0.6659510135650635,
0.8312348127365112,
0.7307031750679016,
0.17303933203220367,
0.21706810593605042,
-0.9719288349151611,
-0.5586418509483337,
-0.4343738853931427,
0.06299328804016113,
-0.05966845154762268,
0.571821928024292,
-1.641867995262146,
0.05286068469285965,
... |
func (rf *Raft) sendAppendEntries(server int, args *AppendEntriesArgs, reply *AppendEntriesReply) bool {
ok := rf.peers[server].Call("Raft.AppendEntries", args, reply)
return ok
} | [
-0.6331875920295715,
0.6935009360313416,
0.594713568687439,
-0.22891725599765778,
0.3724179267883301,
0.043902572244405746,
-0.15011818706989288,
-0.4615994691848755,
-0.021681126207113266,
0.31007474660873413,
-0.6372017860412598,
0.2182137668132782,
-1.2619516849517822,
1.389290809631347... |
func (rf *Raft) Start(command interface{}) (int, int, bool) {
ev := newRaftEV(&DispatchCommandArgs{
Command: command,
})
select {
case <-rf.quitc:
return -1, -1, false
case rf.eventc <- ev:
}
<-ev.c
if ev.result == nil {
return -1, -1, false
}
reply := ev.result.(*DispatchCommandReply)
return reply... | [
-0.509445071220398,
0.1344417780637741,
0.6271233558654785,
-0.3098127245903015,
-0.1756935566663742,
-0.1768469363451004,
1.0138124227523804,
0.04406125843524933,
-0.34498560428619385,
0.6540616750717163,
-1.1842706203460693,
1.137540578842163,
-0.41886335611343384,
0.11314349621534348,
... |
func (rf *Raft) Kill() {
atomic.StoreInt32(&rf.dead, 1)
// Your code here, if desired.
rf.quitOnce.Do(func() {
close(rf.quitc)
rf.routineGroup.Wait()
DPrintf("%v killed", rf.raftInfo())
})
} | [
0.10719861835241318,
0.09021775424480438,
0.6276514530181885,
1.2088958024978638,
0.2920665144920349,
1.0967024564743042,
1.0816930532455444,
-0.10588090866804123,
-0.49935975670814514,
-0.14693643152713776,
-0.223177969455719,
0.7573354244232178,
-0.5664674639701843,
0.37176454067230225,
... |
func Make(peers []*labrpc.ClientEnd, me int,
persister *Persister, applyCh chan ApplyMsg) *Raft {
rf := &Raft{}
rf.peers = peers
rf.persister = persister
rf.me = me
// Your initialization code here (2A, 2B, 2C).
rf.nextIndex = make([]int, len(peers))
rf.matchIndex = make([]int, len(peers))
rf.voteGranted = ma... | [
0.17409442365169525,
0.03153588995337486,
0.8607373833656311,
0.0978691354393959,
-0.32868748903274536,
0.08729814738035202,
0.48404428362846375,
-0.36526232957839966,
-0.17663763463497162,
-1.000135064125061,
0.04213070869445801,
0.1453707069158554,
-0.5076990723609924,
0.1704435050487518... |
func (rf *Raft) startElection() {
DPrintf("%v become-candidate.start-election", rf.raftInfo())
rf.state = RaftCandidate
rf.resetElectionTimeoutTicks()
rf.term++
rf.votedFor = rf.me
rf.persist()
rf.voteGranted = map[int]bool{}
rf.broadcastRequestVote()
} | [
0.051112812012434006,
-0.15476325154304504,
0.3352891802787781,
0.5218272805213928,
0.25321632623672485,
-0.227494016289711,
1.3200703859329224,
0.521469235420227,
0.0059324526228010654,
-0.030257131904363632,
-0.3538186848163605,
1.123645305633545,
-0.41083207726478577,
0.2857617735862732... |
func (rf *Raft) lastLogInfo() (int, int) {
if len(rf.logEntries) == 0 {
return -1, -1
}
logEntry := rf.logEntries[len(rf.logEntries)-1]
return logEntry.Index, logEntry.Term
} | [
-0.36530232429504395,
-0.8288906812667847,
0.8963541984558105,
-1.288330078125,
0.2338518500328064,
-0.36160680651664734,
0.07397893071174622,
-0.036199431866407394,
-0.04811644181609154,
0.008738701231777668,
-0.18923813104629517,
0.2538694441318512,
-0.6269147992134094,
-0.25587439537048... |
func (rf *Raft) logEntriesSince(logIndex int) []raftLogEntry {
if logIndex < 0 {
logIndex = 0
}
return rf.logEntries[logIndex:]
} | [
0.4224407970905304,
0.6288313865661621,
0.7091448903083801,
-0.24508216977119446,
0.2523224353790283,
-0.5363125801086426,
0.44893959164619446,
-0.4839061200618744,
0.6895942091941833,
-0.26599249243736267,
-0.20871300995349884,
0.5753217339515686,
-0.8323653936386108,
-0.10621611028909683... |
func (rf *Raft) logEntryAt(logIndex int) raftLogEntry {
if logIndex < 0 {
panic("logIndex < 0")
}
return rf.logEntries[logIndex]
} | [
0.2698502838611603,
0.026435432955622673,
0.5222502946853638,
-1.6456536054611206,
0.3843800723552704,
-0.4593682587146759,
0.07029943913221359,
-1.1549769639968872,
0.3573104441165924,
-0.0739835798740387,
0.47273242473602295,
0.6048951148986816,
-1.0390312671661377,
-0.6953238248825073,
... |
func New(dburl string) *Store {
return &Store{
DatabaseURL: dburl,
}
} | [
0.21244919300079346,
-0.2628091275691986,
-0.285847008228302,
-0.15475653111934662,
-1.1667300462722778,
0.1322023868560791,
-0.4002094566822052,
0.5083695650100708,
0.8080294132232666,
-0.5545727610588074,
-0.8545083403587341,
0.03719170764088631,
-0.5028625130653381,
0.3148104250431061,
... |
func (s *Store) Open() error {
client, err := mongo.NewClient(options.Client().ApplyURI(s.DatabaseURL))
if err != nil {
return err
}
err = client.Connect(dbctx)
if err != nil {
return err
}
if err = client.Ping(dbctx, nil); err != nil {
return err
}
s.db = client
return nil
} | [
-0.25435420870780945,
0.7440146803855896,
0.24304428696632385,
0.034872833639383316,
-0.03491117060184479,
0.5297571420669556,
0.09921903908252716,
0.9536281824111938,
0.3073158264160156,
0.13518981635570526,
-0.4354212284088135,
0.4731743335723877,
-0.9584854245185852,
-0.0249637681990861... |
func (s *Store) Close() {
s.db.Disconnect(dbctx)
} | [
-0.19426807761192322,
0.15072070062160492,
0.07539123296737671,
-0.1950955092906952,
-0.8849701881408691,
0.5760621428489685,
-0.4446733891963959,
-0.1020021140575409,
0.5703220963478088,
-0.458615779876709,
0.08980612456798553,
-0.2068118304014206,
-0.8684091567993164,
0.6411354541778564,... |
func (s *Store) FindOne(collection string, filter interface{}, opts ...*options.FindOneOptions) (bson.D, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection(collection)
item := col.FindOne(ctx, filter, opts...)
var ... | [
-0.4504603445529938,
0.584432065486908,
0.7682240605354309,
0.7090290784835815,
0.2404613494873047,
0.21927164494991302,
0.1397385597229004,
-0.4432585537433624,
-0.6681323051452637,
0.5518624782562256,
-0.29923194646835327,
0.43308815360069275,
-1.3036863803863525,
-0.15595625340938568,
... |
func (s *Store) FindAll(collection string) ([]bson.D, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection(collection)
cur, err := col.Find(ctx, bson.M{})
if err != nil {
return nil, err
}
items := make([]bson.D... | [
0.375550776720047,
0.08695659041404724,
0.8445816040039062,
0.9531089663505554,
0.4105541408061981,
0.5644204020500183,
-0.37590762972831726,
0.07444977015256882,
-0.3779206871986389,
0.588756799697876,
-0.4375350773334503,
0.444274365901947,
-0.7457960844039917,
1.1666874885559082,
0.52... |
func (s *Store) FindAllPages() ([]models.Page, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection("pages")
cur, err := col.Find(ctx, bson.M{})
if err != nil {
return nil, err
}
pages := make([]models.Page, 0)
... | [
0.5568729639053345,
-0.08977726846933365,
0.3509233295917511,
0.43461012840270996,
0.5423216223716736,
0.12442762404680252,
-1.0461359024047852,
-0.0846286341547966,
0.332416296005249,
0.542023241519928,
0.12652789056301117,
-0.20949861407279968,
-1.091614842414856,
1.6908718347549438,
-... |
func (s *Store) FindAllServices() ([]models.Service, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection("services")
cur, err := col.Find(ctx, bson.M{"deleted": false})
if err != nil {
return nil, err
}
service... | [
0.25053635239601135,
-0.22582955658435822,
0.5610145330429077,
0.5234158039093018,
0.4366593658924103,
0.0628291517496109,
-0.1947697401046753,
-0.36574625968933105,
0.20896674692630768,
-0.06837185472249985,
0.21575529873371124,
-0.4355265200138092,
-1.3956290483474731,
2.0669069290161133... |
func (s *Store) FindAllCategories(filter bson.M) ([]models.Category, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection("categories")
cur, err := col.Find(ctx, filter)
if err != nil {
return nil, err
}
cats :=... | [
0.27650418877601624,
0.4111766815185547,
0.45621758699417114,
0.4480397403240204,
-0.22699294984340668,
-0.20121417939662933,
-0.46741366386413574,
0.108220174908638,
-0.3450873792171478,
-0.5136060118675232,
0.23940812051296234,
-0.3260692059993744,
-0.6711560487747192,
2.1359829902648926... |
func (s *Store) FindAllPosts(filter bson.M, opts ...*options.FindOptions) ([]models.Post, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection("posts")
cur, err := col.Find(ctx, filter, opts...)
// cur, err := col.Fin... | [
0.5279799699783325,
0.3275090157985687,
0.5242487788200378,
0.9572115540504456,
0.018445182591676712,
0.09430065006017685,
-0.5445427298545837,
-0.2022184431552887,
-0.1875878870487213,
0.20395013689994812,
-0.08991269022226334,
-0.002659163437783718,
-0.7893841862678528,
1.352801918983459... |
func (s *Store) CountAllPosts(opts ...*options.CountOptions) (int64, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection("posts")
cnt, err := col.CountDocuments(ctx, bson.M{"deleted": false}, opts...)
if err != nil ... | [
0.4546477198600769,
-0.06689828634262085,
0.7332223057746887,
0.593234121799469,
-0.28904443979263306,
0.2819184362888336,
-0.15590599179267883,
0.49861085414886475,
0.005036307964473963,
0.3809055685997009,
-0.49922141432762146,
-0.3253649175167084,
-0.9061093926429749,
0.6996256113052368... |
func (s *Store) FindMaterials(filter bson.M, opts ...*options.FindOptions) ([]models.Material, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection("materials")
cur, err := col.Find(ctx, filter, opts...)
if err != ni... | [
-0.1322202980518341,
0.07841750234365463,
0.2934351861476898,
0.07806477695703506,
0.1702520251274109,
-0.154271200299263,
-0.2156631350517273,
-0.6327190399169922,
-0.7150017023086548,
-0.13461072742938995,
0.2886812090873718,
-0.09825349599123001,
-0.8517804145812988,
1.7349509000778198,... |
func (s *Store) FindMatcategories(filter bson.M, opts ...*options.FindOptions) ([]models.MatCategory, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection("matcategories")
cur, err := col.Find(ctx, filter, opts...)
i... | [
0.14002880454063416,
0.4152706563472748,
0.4265461564064026,
-0.5653547644615173,
-0.23228038847446442,
0.021438078954815865,
-0.0037819230929017067,
-0.5124746561050415,
-0.5443099141120911,
-0.19261173903942108,
0.37695518136024475,
-0.23045945167541504,
-0.47345900535583496,
1.494124054... |
func (s *Store) InsertOne(collection string, data interface{}) (*mongo.InsertOneResult, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection(collection)
r, err := col.InsertOne(ctx, data)
if err != nil {
return nil... | [
-0.40238693356513977,
0.9250246286392212,
0.7930874228477478,
-0.12423387914896011,
0.7189671993255615,
0.5858609676361084,
0.3411696255207062,
0.09702473133802414,
-0.7065076231956482,
0.2639634609222412,
-1.0338828563690186,
-0.2284134477376938,
-1.8383408784866333,
-0.14495350420475006,... |
func (s *Store) UpdateOne(collection string, filter interface{}, update interface{}) (*mongo.UpdateResult, error) {
var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
db := s.db.Database(dbName)
col := db.Collection(collection)
r, err := col.UpdateOne(
ctx,
filter,
u... | [
-0.6642690896987915,
0.08488347381353378,
0.9881194233894348,
0.5775339007377625,
-0.2792469561100006,
0.1413886994123459,
-0.18535633385181427,
0.25806936621665955,
-0.4206092655658722,
1.3085203170776367,
-0.412302702665329,
0.060998883098363876,
-1.3314800262451172,
-0.2670075595378876,... |
func (p *planner) AlterIndex(ctx context.Context, n *tree.AlterIndex) (planNode, error) {
if err := checkSchemaChangeEnabled(
ctx,
p.ExecCfg(),
"ALTER INDEX",
); err != nil {
return nil, err
}
tableDesc, indexDesc, err := p.getTableAndIndex(ctx, &n.Index, privilege.CREATE)
if err != nil {
return nil, er... | [
-0.1929369419813156,
0.10262317210435867,
0.49108001589775085,
0.03035341016948223,
-0.14349590241909027,
0.04838832840323448,
-0.3652647137641907,
0.14907462894916534,
0.5022311806678772,
-0.36974474787712097,
-0.20056313276290894,
1.3227360248565674,
-0.11487814038991928,
-0.191818863153... |
func (n *alterIndexNode) ReadingOwnWrites() {} | [
-0.7944720387458801,
-0.8466230630874634,
0.31965121626853943,
-0.14316290616989136,
0.18668752908706665,
-0.540603518486023,
1.7168374061584473,
0.27225595712661743,
0.6546604037284851,
-1.0913821458816528,
1.5265896320343018,
0.2978179156780243,
-0.9698024392127991,
-0.06585603952407837,... |
func (c *Citation) CiteID(count int) string {
if count == 0 {
return "footnote-link-" + c.Key
}
return "footnote-link-" + c.Key + "-" + strconv.Itoa(count)
} | [
0.7251332402229309,
-0.4849834442138672,
0.6628645658493042,
-0.2564786970615387,
0.6116466522216797,
0.2786031663417816,
0.16979388892650604,
-0.07282266765832901,
0.4888179302215576,
0.5895029902458191,
0.6779519319534302,
-0.3269664943218231,
-0.5547444820404053,
0.47049209475517273,
... |
func (c *Citation) ReferenceID() string {
return "cite_ref_" + c.Key
} | [
1.1891899108886719,
-1.19884192943573,
0.26643142104148865,
-0.08717776834964752,
0.5474662780761719,
1.2215319871902466,
0.05934031307697296,
-0.01084168441593647,
0.7384861707687378,
1.2014952898025513,
0.7259553074836731,
0.6331995129585266,
-0.054489411413669586,
0.6218811273574829,
... |
func NewGetActionTemplateLogoVersionParams() *GetActionTemplateLogoVersionParams {
var ()
return &GetActionTemplateLogoVersionParams{
timeout: cr.DefaultTimeout,
}
} | [
0.29959845542907715,
-0.5755193829536438,
0.5787146687507629,
0.4479314386844635,
-0.8742072582244873,
-0.7715812921524048,
-0.11895895004272461,
0.47739553451538086,
0.11504300683736801,
0.5455670952796936,
-0.8023909330368042,
1.0244253873825073,
0.31879258155822754,
-0.6541091203689575,... |
func NewGetActionTemplateLogoVersionParamsWithTimeout(timeout time.Duration) *GetActionTemplateLogoVersionParams {
var ()
return &GetActionTemplateLogoVersionParams{
timeout: timeout,
}
} | [
0.6120362281799316,
-0.406076580286026,
0.6551570296287537,
0.5454351902008057,
-0.7554227709770203,
-0.10324324667453766,
-0.7066292762756348,
0.4463731050491333,
0.17680376768112183,
1.423134446144104,
-0.5285724997520447,
1.1576443910598755,
0.33471357822418213,
-0.28903728723526,
-0.... |
func NewGetActionTemplateLogoVersionParamsWithContext(ctx context.Context) *GetActionTemplateLogoVersionParams {
var ()
return &GetActionTemplateLogoVersionParams{
Context: ctx,
}
} | [
0.27348029613494873,
-0.4619985520839691,
1.036643624305725,
0.018854215741157532,
-0.44556117057800293,
-0.04231458529829979,
-0.5279585123062134,
-0.2620999217033386,
0.4354497194290161,
1.0615559816360474,
-0.6520035862922668,
0.9589976668357849,
0.3615068793296814,
-0.7476707696914673,... |
func NewGetActionTemplateLogoVersionParamsWithHTTPClient(client *http.Client) *GetActionTemplateLogoVersionParams {
var ()
return &GetActionTemplateLogoVersionParams{
HTTPClient: client,
}
} | [
0.3091776669025421,
-0.5135020613670349,
0.7018845081329346,
0.3339172601699829,
-0.13779762387275696,
-0.16709232330322266,
-0.012398581951856613,
0.40386566519737244,
-0.34047433733940125,
0.2473634034395218,
-0.6660270690917969,
0.7635709047317505,
0.2405206710100174,
-0.780994117259979... |
func (o *GetActionTemplateLogoVersionParams) WithTimeout(timeout time.Duration) *GetActionTemplateLogoVersionParams {
o.SetTimeout(timeout)
return o
} | [
0.4475608766078949,
-0.09611117839813232,
0.43850743770599365,
-0.11799261718988419,
-1.0606988668441772,
-0.6011977791786194,
-0.20248651504516602,
0.2002178132534027,
0.7761431932449341,
1.0112913846969604,
-0.13585825264453888,
0.9950695633888245,
0.9791333675384521,
-0.2054935395717620... |
func (o *GetActionTemplateLogoVersionParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
} | [
0.08348716050386429,
-0.04000237584114075,
0.35454612970352173,
-0.1635972410440445,
-0.5839686393737793,
-0.17644824087619781,
-0.12233005464076996,
0.6118417978286743,
0.39161717891693115,
0.821643590927124,
-0.167006254196167,
1.3725676536560059,
0.4067484736442566,
-0.20450346171855927... |
func (o *GetActionTemplateLogoVersionParams) WithContext(ctx context.Context) *GetActionTemplateLogoVersionParams {
o.SetContext(ctx)
return o
} | [
-0.11201263219118118,
-0.21434777975082397,
0.6549415588378906,
-0.19563034176826477,
-1.002707600593567,
-0.6008819341659546,
-0.18813514709472656,
-0.49837249517440796,
1.0642318725585938,
0.5491862893104553,
-0.22154980897903442,
0.833785355091095,
0.43622565269470215,
-0.53395962715148... |
func (o *GetActionTemplateLogoVersionParams) SetContext(ctx context.Context) {
o.Context = ctx
} | [
-0.2856370210647583,
0.007401452399790287,
0.43112897872924805,
-0.06106794625520706,
-0.431557297706604,
-0.2998909056186676,
0.08672814816236496,
-0.1608620285987854,
1.0179935693740845,
0.41464024782180786,
-0.41084012389183044,
1.2366955280303955,
0.05037197098135948,
-0.37799349427223... |
func (o *GetActionTemplateLogoVersionParams) WithHTTPClient(client *http.Client) *GetActionTemplateLogoVersionParams {
o.SetHTTPClient(client)
return o
} | [
0.21892644464969635,
-0.7754152417182922,
0.37331441044807434,
-0.3013417720794678,
-0.6345210075378418,
-0.8388872146606445,
0.20369821786880493,
-0.14411203563213348,
0.17980818450450897,
-0.06861623376607895,
-0.2709733545780182,
0.6801912784576416,
0.7124754190444946,
-0.86185902357101... |
func (o *GetActionTemplateLogoVersionParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
} | [
0.2595349848270416,
-0.5182730555534363,
0.3111990988254547,
-0.6083595752716064,
-0.773997962474823,
-0.8895153403282166,
0.29196080565452576,
-0.021608147770166397,
-0.3918355107307434,
0.05394885316491127,
-0.538591742515564,
1.1539716720581055,
0.24030770361423492,
-0.9295617341995239,... |
func (o *GetActionTemplateLogoVersionParams) WithTypeOrID(typeOrID string) *GetActionTemplateLogoVersionParams {
o.SetTypeOrID(typeOrID)
return o
} | [
0.19661159813404083,
-1.1920808553695679,
0.39143943786621094,
-0.01605403423309326,
-0.7399528622627258,
-0.5943211913108826,
-0.2011791467666626,
-0.8149887323379517,
0.8618908524513245,
0.45762181282043457,
0.1579912006855011,
0.8110862374305725,
0.30494260787963867,
-0.2310455143451690... |
func (o *GetActionTemplateLogoVersionParams) SetTypeOrID(typeOrID string) {
o.TypeOrID = typeOrID
} | [
-0.16625113785266876,
-1.4154086112976074,
0.4764229655265808,
-0.002898512640967965,
-0.5737602114677429,
-0.27665165066719055,
0.21134459972381592,
-0.46175849437713623,
0.26702725887298584,
0.2860167324542999,
-0.27162790298461914,
1.1462286710739136,
-0.25272053480148315,
-0.1472399532... |
func (o *GetActionTemplateLogoVersionParams) WithVersion(version int32) *GetActionTemplateLogoVersionParams {
o.SetVersion(version)
return o
} | [
0.030022121965885162,
-0.642815887928009,
0.36339429020881653,
0.20194539427757263,
-0.5783367156982422,
-0.7715064287185669,
0.5684563517570496,
-0.02451491914689541,
0.5239781141281128,
0.5101475715637207,
-0.6996240019798279,
0.13807989656925201,
0.17733974754810333,
-0.4298818111419678... |
func (o *GetActionTemplateLogoVersionParams) SetVersion(version int32) {
o.Version = version
} | [
-0.28787997364997864,
-0.48629918694496155,
0.2767255902290344,
0.323731005191803,
-0.2464553713798523,
-0.4353425204753876,
0.7657929062843323,
0.27922090888023376,
0.32543960213661194,
0.47570058703422546,
-0.8722648024559021,
0.6193727254867554,
-0.12291836738586426,
-0.0777148604393005... |
func (o *GetActionTemplateLogoVersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param typeOrId
if err := r.SetPathParam("typeOrId", o.TypeOrID); err != nil {
return err
}
// path param ve... | [
-1.18252694606781,
-0.35135868191719055,
0.8946871161460876,
-0.55239337682724,
0.5024643540382385,
-0.611430287361145,
0.9467814564704895,
0.08534546941518784,
-0.3051097095012665,
0.5379759669303894,
0.08029775321483612,
0.8543928861618042,
-0.156692773103714,
-0.17363682389259338,
0.9... |
func NewMockContainer() *Container {
var container Container
container.AccountsHandler = service.NewAccountsHandler()
container.AccountsRepository = repository.NewAccountsPersistenceHandler()
return &container
} | [
0.3280823826789856,
0.44206008315086365,
0.24206136167049408,
0.23777948319911957,
0.24176053702831268,
-0.5274384617805481,
1.2483681440353394,
-0.30681267380714417,
0.6205154657363892,
-0.4913632571697235,
0.00946653913706541,
-0.11181699484586716,
0.10858339816331863,
1.4521098136901855... |
func FixedOffsetTimeZoneToLocation(offset int, origRepr string) *time.Location {
return time.FixedZone(
fmt.Sprintf("%s%d (%s)", fixedOffsetPrefix, offset, origRepr),
offset)
} | [
-0.41361531615257263,
-1.1730213165283203,
0.05988723039627075,
-1.039129614830017,
-0.8363614082336426,
-0.14812354743480682,
1.414334774017334,
0.11847051233053207,
0.35991793870925903,
0.4978528618812561,
-0.10992669314146042,
0.6108974814414978,
-0.2546231746673584,
-0.3388911187648773... |
func TimeZoneStringToLocation(
locStr string, std TimeZoneStringToLocationStandard,
) (*time.Location, error) {
offset, origRepr, parsed := ParseFixedOffsetTimeZone(locStr)
if parsed {
return FixedOffsetTimeZoneToLocation(offset, origRepr), nil
}
// The time may just be a raw int value.
intVal, err := strconv.... | [
-0.5464217662811279,
-1.0814708471298218,
0.22271855175495148,
-0.5065448880195618,
-0.8924948573112488,
-0.5155227184295654,
1.0352216958999634,
-0.1141352653503418,
0.42535850405693054,
0.64679354429245,
-0.28916409611701965,
-0.07001810520887375,
0.1375998854637146,
-0.632655143737793,
... |
func ParseFixedOffsetTimeZone(location string) (offset int, origRepr string, success bool) {
if !strings.HasPrefix(location, fixedOffsetPrefix) {
return 0, "", false
}
location = strings.TrimPrefix(location, fixedOffsetPrefix)
parts := strings.SplitN(location, " ", 2)
if len(parts) < 2 {
return 0, "", false
}... | [
-0.6585177779197693,
-0.6404949426651001,
0.5122454166412354,
-0.8276222348213196,
-1.1643431186676025,
-0.8391034007072449,
1.0002254247665405,
0.38077059388160706,
0.5765821933746338,
1.040112853050232,
-1.173998475074768,
0.421006977558136,
-0.2803950905799866,
0.8232391476631165,
0.9... |
func New(ctx context.Context, params ...Parameter) (*Service, error) {
parameters, err := parseAndCheckParameters(params...)
if err != nil {
return nil, errors.Wrap(err, "problem with parameters")
}
// Set logging.
log = zerologger.With().Str("service", "fetcher").Str("impl", "mem").Logger()
if parameters.logL... | [
0.21237313747406006,
-0.6182990670204163,
0.4972546696662903,
-0.43980374932289124,
-0.9321249127388,
0.03236010670661926,
-0.21660135686397552,
-0.8548559546470642,
-0.5111167430877686,
0.19566470384597778,
0.3974875807762146,
0.7038866281509399,
0.2001638412475586,
0.9716007709503174,
... |
func (s *Service) FetchWallet(ctx context.Context, path string) (e2wtypes.Wallet, error) {
log := log.With().Str("path", path).Logger()
log.Trace().Msg("Fetching wallet")
walletName, _, err := e2wallet.WalletAndAccountNames(path)
if err != nil {
log.Warn().Msg("Invalid path")
return nil, errors.Wrap(err, "inva... | [
0.08564108610153198,
-0.4156935214996338,
0.702995240688324,
-0.05015463009476662,
-0.4573620855808258,
-0.28297159075737,
0.0282271858304739,
-0.5590835809707642,
0.9356741905212402,
0.423384428024292,
0.46667104959487915,
0.4930669367313385,
0.2013227790594101,
0.9535788893699646,
-0.2... |
func (s *Service) FetchAccount(ctx context.Context, path string) (e2wtypes.Wallet, e2wtypes.Account, error) {
log := log.With().Str("path", path).Logger()
log.Trace().Msg("Fetching account")
// Fetch account and store in cache if present.
wallet, err := s.FetchWallet(ctx, path)
if err != nil {
return nil, nil, ... | [
0.19517159461975098,
-0.5237691402435303,
0.6582738757133484,
0.1849087029695511,
-0.7425816059112549,
-0.33436715602874756,
0.676836371421814,
-0.5416622161865234,
0.9118543863296509,
0.9419986009597778,
0.014597256667912006,
0.6841706037521362,
0.1741032749414444,
0.6527438759803772,
-... |
func (s *Service) FetchAccountByKey(ctx context.Context, pubKey []byte) (e2wtypes.Wallet, e2wtypes.Account, error) {
log := log.With().Str("public_key", fmt.Sprintf("%#x", pubKey)).Logger()
log.Trace().Msg("Fetching account by key")
// See if we already know this key.
s.pubKeyPathsMx.RLock()
account, exists := s.... | [
0.45667707920074463,
-0.41245943307876587,
0.4941878020763397,
0.15709207952022552,
-0.5817126035690308,
-0.7109005451202393,
0.7156712412834167,
-0.2820887565612793,
0.7191504836082458,
0.5923783183097839,
-0.11715885251760483,
0.050975967198610306,
-0.17286674678325653,
0.806229233741760... |
func search(nums []int, target int) int {
for i,v := range nums {
if v == target {
return i
}
}
return -1
} | [
-1.120608925819397,
-0.40463751554489136,
0.5542078614234924,
-0.05677726864814758,
0.016095992177724838,
-0.048171788454055786,
0.6163540482521057,
0.019579851999878883,
0.001874847337603569,
0.35259321331977844,
0.8273786902427673,
1.008866310119629,
-0.44311201572418213,
-0.277719855308... |
func (format *Double) Configure(conf core.PluginConfigReader) error {
format.SimpleFormatter.Configure(conf)
format.left = conf.GetFormatterArray("Left", format.Log, core.FormatterArray{})
format.right = conf.GetFormatterArray("Right", format.Log, core.FormatterArray{})
format.separator = []byte(conf.GetString("Sep... | [
-0.3593924343585968,
-0.685753345489502,
0.6859056353569031,
-0.28825002908706665,
-0.06266374886035919,
-1.0955222845077515,
-0.4286232888698578,
-0.5261443257331848,
-0.5779104828834534,
0.16361035406589508,
-0.5429353713989258,
-0.23387403786182404,
-0.19589149951934814,
1.4666705131530... |
func (format *Double) ApplyFormatter(msg *core.Message) error {
leftMsg := msg.Clone()
rightMsg := msg.Clone()
// pre-process
if format.applyTo != core.ApplyToPayloadString {
leftMsg.StorePayload(format.GetAppliedContent(msg))
rightMsg.StorePayload(format.GetAppliedContent(msg))
}
// apply sub-formatter
if... | [
-0.1376819759607315,
-0.3991449177265167,
1.0183029174804688,
-0.7347292304039001,
-1.169325828552246,
0.19825072586536407,
0.03492986783385277,
-0.7160507440567017,
-0.022952105849981308,
-0.6108417510986328,
0.16152115166187286,
0.394476056098938,
-0.5346158742904663,
2.4305896759033203,... |
func (m OrderRepository) Order(context.Context) (*model.Order, error) {
return m.OrderResponse, m.Err
} | [
-0.8773757815361023,
-0.34595993161201477,
0.17478638887405396,
0.2544933259487152,
1.0074964761734009,
-0.6372250914573669,
-0.3711128830909729,
-0.3591555953025818,
0.7947126030921936,
-0.545284628868103,
-0.10602465271949768,
-0.47486886382102966,
-0.10001283884048462,
0.620821774005889... |
func (m OrderRepository) List(context.Context) ([]*model.Order, error) {
return m.ListResponse, m.Err
} | [
-0.7489847540855408,
-0.6965970396995544,
0.06882546842098236,
0.2885725498199463,
1.652788758277893,
-0.7337305545806885,
-0.36474862694740295,
-0.059937793761491776,
0.5206103920936584,
0.14898434281349182,
-0.5735597014427185,
-0.3891667127609253,
-0.04538573697209358,
0.659686684608459... |
func (suite *HostCacheTestSuite) TestMesosHostSummarySetCapacity() {
ms := newMesosHostSummary(_hostname, _version).(*mesosHostSummary)
available := scalar.Resources{
CPU: 1.0,
Mem: 100.0,
}
allocated := scalar.Resources{
CPU: 2.0,
Mem: 200.0,
}
capacity := scalar.Resources{
CPU: 3.0,
Mem: 300.0,
}
... | [
0.1306372880935669,
-0.022815950214862823,
0.6328449249267578,
0.1218147873878479,
-0.3506618142127991,
-0.006643891334533691,
0.8739804029464722,
0.13683031499385834,
-0.4038723409175873,
0.023045804351568222,
-0.16365471482276917,
0.09314162284135818,
1.0580878257751465,
0.63483279943466... |
func (suite *HostCacheTestSuite) TestMesosHostSummaryHandlePodEvent() {
ms := newMesosHostSummary(_hostname, _version).(*mesosHostSummary)
suite.NoError(ms.HandlePodEvent(nil))
} | [
0.16769711673259735,
0.4678459167480469,
0.6349023580551147,
0.44962602853775024,
0.14918549358844757,
1.1099942922592163,
0.5589949488639832,
0.4187944531440735,
-0.1630355566740036,
-1.2024905681610107,
-0.6423093676567078,
-0.24488255381584167,
0.3007905185222626,
0.151899516582489,
0... |
func (suite *HostCacheTestSuite) TestMesosHostSummarySetAvailable() {
testTable := map[string]struct {
capacity scalar.Resources
available scalar.Resources
expectedAllocated scalar.Resources
}{
"normal-test-case-1": {
capacity: scalar.Resources{
CPU: 4.0,
Mem: 100.0,
},
avail... | [
0.007338962983340025,
0.15196548402309418,
0.6171623468399048,
-0.015726961195468903,
-0.46891120076179504,
0.41085296869277954,
0.606977641582489,
0.45011740922927856,
-0.7202014923095703,
0.16593734920024872,
-0.5980132222175598,
0.3806789219379425,
0.9124546051025391,
0.6274057030677795... |
func (a adapter) HealthCheck() (model.HealthStatus, error) {
var err error
if a.registry.Credential == nil ||
len(a.registry.Credential.AccessKey) == 0 || len(a.registry.Credential.AccessSecret) == 0 {
log.Errorf("no credential to ping registry %s", a.registry.URL)
return model.Unhealthy, nil
}
if err = a.Pin... | [
-0.41120097041130066,
-0.3905847370624542,
0.6602097749710083,
0.19564670324325562,
0.5158379673957825,
0.8673660159111023,
0.4602873623371124,
0.34130480885505676,
0.5425918102264404,
0.12186919897794724,
0.8669986724853516,
0.92754065990448,
0.08667125552892685,
-0.04544728249311447,
0... |
func NewDefaultRPCGenerator(style string) (*RPCGenerator, error) {
cfg, err := conf.NewConfig(style)
if err != nil {
return nil, err
}
return NewRPCGenerator(NewDefaultGenerator(), cfg), nil
} | [
-0.7849640250205994,
-0.1981586515903473,
0.32006093859672546,
-0.21510113775730133,
-0.36146071553230286,
-0.652904748916626,
-0.5752962231636047,
-0.4880678951740265,
0.00028004846535623074,
-0.07880318909883499,
-0.516217052936554,
-0.5362852215766907,
-1.5741833448410034,
1.51007211208... |
func NewRPCGenerator(g Generator, cfg *conf.Config) *RPCGenerator {
return &RPCGenerator{
g: g,
cfg: cfg,
}
} | [
-0.5004627108573914,
-0.6413346529006958,
0.3067212402820587,
-0.660426676273346,
-1.2261415719985962,
-0.17491336166858673,
-0.09219837188720703,
-0.1589200347661972,
-0.34900492429733276,
-0.20800845324993134,
-0.42954838275909424,
-0.7306880950927734,
-1.1723217964172363,
1.137928962707... |
func (g *RPCGenerator) Generate(src, target string, protoImportPath []string, goOptions ...string) error {
abs, err := filepath.Abs(target)
if err != nil {
return err
}
err = util.MkdirIfNotExist(abs)
if err != nil {
return err
}
err = g.g.Prepare()
if err != nil {
return err
}
projectCtx, err := ctx... | [
-0.17012454569339752,
0.8449328541755676,
0.9705637693405151,
0.3807465434074402,
0.4870043992996216,
1.1107666492462158,
0.6930157542228699,
-0.6845012307167053,
-0.6482927799224854,
0.05176014080643654,
-0.20020654797554016,
0.2547529637813568,
-0.7391467094421387,
1.0495901107788086,
... |
func NewUniformSample(reservoirSize int) gometrics.Sample {
return &UniformSample{
reservoirSize: reservoirSize,
values: make([]int64, 0, reservoirSize),
}
} | [
-0.21930836141109467,
0.3215693533420563,
0.17838001251220703,
-0.2686634659767151,
-1.0720940828323364,
-0.0815490335226059,
-0.06165744736790657,
0.0016043363139033318,
0.3844524025917053,
-0.5183271169662476,
-0.018638204783201218,
0.2872798442840576,
-0.5592164993286133,
0.174029082059... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.