text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func TestFisherYatesShuffleDistributionWithFiveElementsNative(t *testing.T) {
VerifyShuffleIsUniformlyDistributed(&UniformDistributionTestConfig{testState: t, shuffle: FisherYatesShuffle, runs: 10000000, elements: 5, errorDelta: 5000})
} | [
-0.48999160528182983,
0.4454144835472107,
0.19825728237628937,
-0.288944274187088,
0.39158615469932556,
0.38113951683044434,
1.3295438289642334,
-0.823347806930542,
0.9883855581283569,
-0.5083839297294617,
-1.1911566257476807,
0.6046106219291687,
0.30232876539230347,
1.611100673675537,
-... |
func TestFisherYatesShuffleDistributionWithTenElementsNative(t *testing.T) {
VerifyShuffleIsUniformlyDistributed(&UniformDistributionTestConfig{testState: t, shuffle: FisherYatesShuffle, runs: 10000000, elements: 10, errorDelta: 3000})
} | [
-0.31467199325561523,
0.6797342896461487,
0.44133955240249634,
-0.5540986657142639,
1.2227036952972412,
0.5264983773231506,
1.1696268320083618,
-0.16979554295539856,
1.2774347066879272,
-0.7857376933097839,
-1.1466798782348633,
0.6787545680999756,
0.3942614495754242,
1.5197293758392334,
... |
func TestFisherYatesShuffleDistributionWithFiftyElementsNative(t *testing.T) {
VerifyShuffleIsUniformlyDistributed(&UniformDistributionTestConfig{testState: t, shuffle: FisherYatesShuffle, runs: 6000000, elements: 50, errorDelta: 1500})
} | [
-0.5513467192649841,
0.24344311654567719,
0.23665165901184082,
-0.16953054070472717,
0.5076453685760498,
0.2793518006801605,
1.114376187324524,
-0.7740424871444702,
1.498698353767395,
-0.6702455878257751,
-0.7960790395736694,
0.5947422385215759,
0.6906107068061829,
1.8360941410064697,
0.... |
func NewGetVersionsOK() *GetVersionsOK {
return &GetVersionsOK{}
} | [
-0.13386031985282898,
0.5087884068489075,
0.022940127179026604,
1.7295911312103271,
0.45477306842803955,
-1.1376105546951294,
0.13838331401348114,
0.007041304837912321,
-0.15488478541374207,
0.13645534217357635,
-0.6900548934936523,
-0.37971290946006775,
0.11987948417663574,
0.131512016057... |
func (o *GetVersionsOK) WithPayload(payload *GetVersionsOKBody) *GetVersionsOK {
o.Payload = payload
return o
} | [
0.1875099390745163,
0.7489374876022339,
-0.032828718423843384,
0.8798310160636902,
-0.08339276164770126,
-0.726351261138916,
-0.27532297372817993,
-0.7867839336395264,
0.602404773235321,
0.3214903473854065,
-0.4608137309551239,
-0.4177280366420746,
0.5345802307128906,
-0.3324223458766937,
... |
func (o *GetVersionsOK) SetPayload(payload *GetVersionsOKBody) {
o.Payload = payload
} | [
0.04548700526356697,
0.8921628594398499,
-0.055355269461870193,
0.9611440300941467,
0.2654755413532257,
-0.21455349028110504,
-0.127353698015213,
-0.5170009732246399,
0.3952648937702179,
0.5725107192993164,
-0.7621836066246033,
0.026258768513798714,
0.013807757757604122,
-0.045240201056003... |
func (o *GetVersionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
} | [
-0.42215093970298767,
-0.05542727932333946,
0.3033767640590668,
0.8050771951675415,
0.803430438041687,
-0.638243556022644,
0.20740804076194763,
-0.24051940441131592,
0.24903680384159088,
0.9179598689079285,
-0.06619928032159805,
-0.48189306259155273,
-0.13479185104370117,
-0.22103242576122... |
func (app *application) RetrieveAll() (lists.Lists, error) {
// retrieve the identity:
identity, err := app.identityRepository.Retrieve(app.name, app.seed, app.password)
if err != nil {
return nil, err
}
return identity.Wallet().Lists(), nil
} | [
0.9287912845611572,
-0.016697276383638382,
0.22562849521636963,
1.080500841140747,
1.083497166633606,
0.15320931375026703,
-1.5224093198776245,
0.4383124113082886,
1.041811227798462,
-0.22763265669345856,
-0.40148818492889404,
-0.5261917114257812,
-0.30957189202308655,
1.1778979301452637,
... |
func (app *application) Retrieve(listHashStr string) (list.List, error) {
// retrieve the identity:
identity, err := app.identityRepository.Retrieve(app.name, app.seed, app.password)
if err != nil {
return nil, err
}
listHash, err := app.hashAdapter.FromString(listHashStr)
if err != nil {
return nil, err
}
... | [
0.8027446866035461,
-0.154351606965065,
0.3123774528503418,
0.5844186544418335,
0.7085747122764587,
-0.4510636031627655,
-1.642275333404541,
0.5091438293457031,
1.5292466878890991,
0.21877458691596985,
-0.23031851649284363,
-0.7496721744537354,
-0.7076058983802795,
0.2997397780418396,
-0... |
func (app *application) New(name string, description string) error {
// retrieve the identity:
identity, err := app.identityRepository.Retrieve(app.name, app.seed, app.password)
if err != nil {
return err
}
list, err := app.listBuilder.Create().WithName(name).WithDescription(description).Now()
if err != nil {
... | [
0.23070381581783295,
-0.12389800697565079,
0.4762774109840393,
-0.02151344157755375,
0.0038140546530485153,
0.009862464852631092,
-1.72527015209198,
0.3070671856403351,
0.36028140783309937,
1.0085147619247437,
-0.798959493637085,
-0.6901528239250183,
0.0681820660829544,
1.1924681663513184,... |
func (app *application) Update(listHashStr string, update Update) error {
// retrieve the identity:
identity, err := app.identityRepository.Retrieve(app.name, app.seed, app.password)
if err != nil {
return err
}
listHash, err := app.hashAdapter.FromString(listHashStr)
if err != nil {
return err
}
list, er... | [
-0.08019828796386719,
-0.8123191595077515,
0.42557668685913086,
0.45744138956069946,
-0.18438272178173065,
0.24809156358242035,
-1.9284635782241821,
0.8860101103782654,
1.087904453277588,
0.622655987739563,
-0.5493964552879333,
-0.7565488219261169,
-0.684147298336029,
0.8555184006690979,
... |
func (app *application) Delete(listHashStr string) error {
// retrieve the identity:
identity, err := app.identityRepository.Retrieve(app.name, app.seed, app.password)
if err != nil {
return err
}
listHash, err := app.hashAdapter.FromString(listHashStr)
if err != nil {
return err
}
return identity.Wallet(... | [
0.9747257232666016,
0.052821412682533264,
0.40897226333618164,
1.0629332065582275,
0.5191004872322083,
0.38695332407951355,
-1.0896402597427368,
0.7543337941169739,
1.4322047233581543,
0.8652308583259583,
-0.3592779338359833,
-0.664149284362793,
-0.9451438188552856,
0.5876384973526001,
-... |
func (app *application) Contacts(listHashStr string) (contacts.Application, error) {
list, err := app.Retrieve(listHashStr)
if err != nil {
return nil, err
}
return app.contactsAppBuilder.Create().WithName(app.name).WithPassword(app.password).WithSeed(app.seed).WithList(list.Hash().String()).Now()
} | [
0.03959380090236664,
-0.6911903619766235,
0.4711412489414215,
0.6154957413673401,
-0.11639126390218735,
-0.03008405864238739,
-0.9138641953468323,
-0.41862034797668457,
1.154785394668579,
-0.12362111359834671,
-0.1283552199602127,
-0.853615939617157,
-0.03019937127828598,
0.768129587173461... |
func NewDatabase(host string, port int, username string, password string, dbname string) (*Database, error) {
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local",
username, password, host, port, dbname)
// TODO: Setup logger for gorm here
// I should implement GORM's logger interface... | [
0.08371583372354507,
-0.5983521938323975,
0.8062137365341187,
0.5211811661720276,
-0.01614871434867382,
-0.24907201528549194,
-0.33011260628700256,
0.32846954464912415,
-0.3993335962295532,
-0.1341865509748459,
-0.2917913496494293,
-0.2872922718524933,
-0.725079357624054,
0.743580758571624... |
func (db *Database) Close() error {
sqlDB, err := db.conn.DB()
if err != nil {
return err
}
return sqlDB.Close()
} | [
-0.20553743839263916,
0.7117303013801575,
0.3425442576408386,
0.2534564137458801,
-0.06171170622110367,
0.5068323612213135,
-0.7862012982368469,
-0.48601236939430237,
-0.2671118378639221,
-0.21931959688663483,
0.5231789946556091,
-0.34915822744369507,
-1.4297186136245728,
1.055745959281921... |
func (db *Database) HealthCheck() error {
sqlDB, err := db.conn.DB()
if err != nil {
return err
}
err = sqlDB.Ping()
if err != nil {
return err
}
return nil
} | [
0.4128822684288025,
0.15998345613479614,
0.7312660813331604,
0.42922914028167725,
1.2464466094970703,
0.9442495703697205,
0.21071724593639374,
0.31122416257858276,
-0.34155037999153137,
0.39355984330177307,
0.5471201539039612,
0.37393149733543396,
-0.03823211416602135,
0.4577910900115967,
... |
func (db *Database) FindAllFeedRecords(provider string, category string, enabled bool) ([]Feed, error) {
var feedResults []Feed
chain := db.conn.Joins("Provider").Joins("Category")
if provider != "" {
chain = chain.Where("`Provider`.`name` = ?", provider)
}
if category != "" {
chain = chain.Where("`Category`... | [
0.6744657754898071,
-0.1235756054520607,
0.8721914291381836,
0.5327451825141907,
-0.24819186329841614,
-0.5262406468391418,
-1.258750557899475,
-0.006373899057507515,
-0.5844929218292236,
0.8215662837028503,
-0.04300881177186966,
0.6511656045913696,
-1.6421349048614502,
1.652198076248169,
... |
func (db *Database) InsertFeedRecord(url string, provider string, category string, enabled bool) error {
// Add Provider if it doesn't exist
var providerRecord Provider
result := db.conn.Where(Provider{Name: provider}).FirstOrCreate(&providerRecord)
if result.Error != nil {
return result.Error
}
// Add Categor... | [
0.284793883562088,
0.8409144878387451,
0.9163519740104675,
-0.31264927983283997,
0.44442018866539,
0.3010137379169464,
-0.24706140160560608,
0.564328670501709,
-0.4616747498512268,
0.307168573141098,
-0.6340208649635315,
-0.26147741079330444,
-1.6882668733596802,
1.121669888496399,
-0.01... |
func (db *Database) UpdateFeedState(url string, enabled bool) error {
// First check record exists
var feedRecord Feed
result := db.conn.Where(&Feed{URL: url}).Take(&feedRecord)
if result.Error != nil {
return result.Error
}
result = db.conn.Model(&Feed{URL: url}).Update("enabled", enabled)
return result.Erro... | [
-0.0510062649846077,
-0.42940372228622437,
0.6198251843452454,
-0.4349697530269623,
-0.700056791305542,
0.41241228580474854,
-0.48017555475234985,
1.0786930322647095,
0.41212859749794006,
0.7279784679412842,
-0.8119948506355286,
0.0881962701678276,
-1.175575613975525,
0.07103610783815384,
... |
func (db *Database) DeleteFeedRecord(url string) error {
// First check record exists
var feedRecord Feed
result := db.conn.Where(&Feed{URL: url}).Take(&feedRecord)
if result.Error != nil {
return result.Error
}
result = db.conn.Where(&Feed{URL: url}).Delete(&feedRecord)
return result.Error
} | [
0.6625256538391113,
-0.24044200778007507,
0.6886045336723328,
-0.16758041083812714,
0.3279547095298767,
-0.2645174264907837,
0.021403074264526367,
0.4164808690547943,
-0.31149327754974365,
-0.3629477620124817,
-0.2850777208805084,
-0.05286535993218422,
-0.3978576064109802,
1.59916234016418... |
func RunTests(ctx context.Context, w io.Writer, path string) error {
if path == "" || path == "." {
var err error
path, err = os.Getwd()
if err != nil {
return err
}
}
files, err := getTestFiles(ctx, path)
if err != nil {
return err
}
for i := range files {
err = runFile(ctx, &files[i])
if err ... | [
-0.2616414427757263,
0.27107954025268555,
0.6877397298812866,
0.12081634998321533,
0.32288312911987305,
0.17511311173439026,
1.2774537801742554,
-0.23510883748531342,
0.12159019708633423,
-1.1303867101669312,
0.8596234321594238,
0.23547567427158356,
-1.013703465461731,
0.3130129277706146,
... |
func getTestFiles(ctx context.Context, path string) ([]File, error) {
var files []File
fs := ctxfs.SourceFsFrom(ctx)
err := afero.Walk(fs, path, func(path string, info os.FileInfo, walkErr error) error {
if walkErr != nil {
return walkErr
}
if info.IsDir() {
// Skip hidden dirs.
if strings.HasPrefix... | [
-0.06501705944538116,
0.1011943444609642,
0.8664770722389221,
0.33735090494155884,
-0.28436338901519775,
-0.16781651973724365,
0.5825854539871216,
-1.1227149963378906,
0.3234512209892273,
0.2649623155593872,
0.309943288564682,
0.2870383560657501,
-0.8141171932220459,
0.23697969317436218,
... |
func runFile(ctx context.Context, file *File) error {
ctx = importcache.WithNewImportCache(ctx)
expr, err := syntax.Compile(ctx, file.Path, file.Source)
if err != nil {
return fmt.Errorf("failed compiling tests file '%s': %v", file.Path, err)
}
start := time.Now()
results, err := RunExpr(ctx, expr)
file.WallT... | [
-0.39620786905288696,
0.0870707705616951,
0.7255722284317017,
-0.22874881327152252,
0.6563791632652283,
0.5973352193832397,
0.8572418689727783,
0.6226290464401245,
-1.1172090768814087,
-0.2956535220146179,
-0.17270968854427338,
0.3364371061325073,
-0.6806197762489319,
0.7175720930099487,
... |
func RunExpr(ctx context.Context, expr rel.Expr) ([]Result, error) {
result, err := expr.Eval(ctx, rel.Scope{})
if err != nil {
return nil, err
}
results := make([]Result, 0)
ForeachLeaf(result, "", func(val rel.Value, path string) {
result := Result{
Name: path,
}
if isLiteralTrue(val) {
result.Ou... | [
-0.9467284083366394,
-0.2846447825431824,
0.8074032664299011,
0.26221394538879395,
-0.29107236862182617,
0.25559839606285095,
-0.2231280356645584,
-0.42276531457901,
-0.47938087582588196,
1.0043668746948242,
0.6993096470832825,
0.15891698002815247,
-0.46170029044151306,
0.3243197202682495,... |
func (this *EtcdUi) InitClientConn() {
if this.Version != "2" {
cli, err := clientv3.New(clientv3.Config{
Endpoints: this.Endpoints,
DialTimeout: 5 * time.Second,
Username: this.Username,
Password: this.Password,
})
if err != nil {
//fmt.Println(err.Error())
panic(err)
}
this.Client... | [
-0.5761010646820068,
-0.45388519763946533,
0.7514066100120544,
0.4801311194896698,
-1.0799413919448853,
0.15696212649345398,
-0.45957767963409424,
0.09203071892261505,
-1.1646766662597656,
-0.2351129949092865,
-0.5297516584396362,
0.8887336850166321,
0.4555875360965729,
0.11488868296146393... |
func (unit *Unit) GetObj(ind uint32) IObject {
return unit.VM.Objects[ind&NSIndex]
} | [
-0.1568962186574936,
0.3164268434047699,
0.3963080942630768,
0.13534927368164062,
0.2495228350162506,
0.9803969264030457,
1.013457179069519,
-1.3653522729873657,
-0.391523540019989,
-0.8439818024635315,
0.6790542602539062,
0.24977374076843262,
0.22207342088222504,
-0.8869744539260864,
-0... |
func (unit *Unit) FindObj(fullName string) IObject {
if ind, ok := unit.NameSpace[fullName]; ok {
return unit.VM.Objects[ind&NSIndex]
}
return nil
} | [
0.24168460071086884,
-0.32575246691703796,
0.5604192614555359,
0.2573763430118561,
-0.29379895329475403,
0.439413845539093,
0.7446239590644836,
-1.2036373615264893,
-0.0018995869904756546,
-0.1298324018716812,
0.5351130962371826,
-0.4179414212703705,
-0.3362615704536438,
0.1786887347698211... |
func (unit *Unit) FindType(name string) IObject {
return unit.FindObj(npType + name)
} | [
-0.2880088686943054,
-0.4199283719062805,
0.43789830803871155,
0.08994169533252716,
0.3683720827102661,
-0.09829611331224442,
0.558772087097168,
-2.4835495948791504,
-0.13534466922283173,
0.5780303478240967,
-0.30382177233695984,
-0.43278422951698303,
-0.9004144668579102,
0.294147878885269... |
func (unit *Unit) FindConst(name string) IObject {
return unit.FindObj(npConst + name)
} | [
0.11702455580234528,
-0.815333902835846,
0.5782539248466492,
-0.19097492098808289,
-0.7002817392349243,
0.5714975595474243,
0.15857897698879242,
-1.4415757656097412,
-0.9279389977455139,
0.6232739686965942,
-0.23238836228847504,
-0.3772866725921631,
-0.4237309694290161,
0.21530848741531372... |
func (unit *Unit) FindFunc(name string, params []*TypeObject) (IObject, bool) {
var isStruct bool
key := npFunc + name
keyAny := key
for _, v := range params {
if v == nil {
return nil, false
}
parName := v.GetName()
key += npFunc + parName
if strings.HasPrefix(parName, `arr.`) {
keyAny += npFunc + ... | [
-0.348031222820282,
-0.5019097328186035,
0.9635211229324341,
0.05828700587153435,
-0.25014734268188477,
-0.5814429521560669,
0.7424905300140381,
-0.9951329827308655,
-0.6309642791748047,
0.23590105772018433,
0.26537829637527466,
-0.21133457124233246,
-0.13307565450668335,
0.799663007259368... |
func (unit *Unit) AddConst(name string) {
ind := uint32(len(unit.VM.Objects) - 1)
obj := unit.GetObj(ind).(*ConstObject)
if obj.Pub {
ind |= NSPub
}
unit.NameSpace[npConst+name] = ind
} | [
-0.43310660123825073,
-0.3672148287296295,
0.8322546482086182,
-0.21997235715389252,
-0.14223970472812653,
1.1353495121002197,
-0.3800380825996399,
-0.006162561010569334,
0.1175181046128273,
-0.05853280797600746,
-0.46262919902801514,
0.22926919162273407,
-0.3859012722969055,
0.46319854259... |
func (unit *Unit) AddFunc(ind int, obj IObject, pub bool) {
var key string
if pub {
ind |= NSPub
}
name := obj.GetName()
if IsVariadic(obj) {
key = npVariadic + name
} else {
key = npFunc + name
for _, v := range obj.GetParams() {
key += npFunc + v.GetName()
}
}
unit.NameSpace[key] = uint32(ind)
} | [
-0.3866466283798218,
0.28238731622695923,
0.4999893307685852,
-0.18893131613731384,
0.3026881515979767,
0.19200004637241364,
0.41323620080947876,
-0.5115719437599182,
-0.007388239726424217,
-0.33350300788879395,
0.26257842779159546,
0.5028423070907593,
0.9686514139175415,
0.234238177537918... |
func New(config *Config) (*TowerClient, error) {
// Copy the config to prevent side-effects from modifying both the
// internal and external version of the Config.
cfg := new(Config)
*cfg = *config
// Set the read timeout to the default if none was provided.
if cfg.ReadTimeout <= 0 {
cfg.ReadTimeout = DefaultR... | [
0.22592541575431824,
-0.8702677488327026,
0.6839065551757812,
0.01462570484727621,
-0.14245884120464325,
-0.44332295656204224,
0.5742037892341614,
-0.46328994631767273,
-0.20891210436820984,
0.5959920883178711,
-0.5800972580909729,
0.3908352255821228,
-0.4677615463733673,
0.539563357830047... |
func (c *TowerClient) Start() error {
var err error
c.started.Do(func() {
log.Infof("Starting watchtower client")
// First, restart a session queue for any sessions that have
// committed but unacked state updates. This ensures that these
// sessions will be able to flush the committed updates after a
// r... | [
0.814175546169281,
-1.0375105142593384,
0.5360432267189026,
0.03182473033666611,
0.7114753723144531,
-0.6818317174911499,
0.9849368333816528,
0.5456513166427612,
-0.1837616264820099,
0.3267687261104584,
-0.3571050763130188,
0.5861825942993164,
-0.0029818518087267876,
-0.07122606784105301,
... |
func (c *TowerClient) Stop() error {
c.stopped.Do(func() {
log.Debugf("Stopping watchtower client")
// 1. Shutdown the backup queue, which will prevent any further
// updates from being accepted. In practice, the links should be
// shutdown before the client has been stopped, so all updates
// would have be... | [
0.066960409283638,
-0.7910298109054565,
0.7062162756919861,
-0.194553405046463,
-0.19436606764793396,
-0.31130510568618774,
0.9090964794158936,
-0.8638373017311096,
-0.2874804437160492,
0.5345200300216675,
-0.6893863677978516,
0.09853033721446991,
-0.2596386671066284,
-0.5226108431816101,
... |
func (c *TowerClient) ForceQuit() {
c.forced.Do(func() {
log.Infof("Force quitting watchtower client")
// 1. Shutdown the backup queue, which will prevent any further
// updates from being accepted. In practice, the links should be
// shutdown before the client has been stopped, so all updates
// would have... | [
0.02970300242304802,
-0.7287731170654297,
0.521026611328125,
-0.43759676814079285,
0.6395543813705444,
0.23059611022472382,
0.5845411419868469,
-1.0902814865112305,
-0.41846320033073425,
0.25416430830955505,
-0.5033740401268005,
0.4945358633995056,
-0.02153157815337181,
0.295545369386673,
... |
func (c *TowerClient) RegisterChannel(chanID lnwire.ChannelID) error {
c.sweepPkScriptMu.Lock()
defer c.sweepPkScriptMu.Unlock()
// If a pkscript for this channel already exists, the channel has been
// previously registered.
if _, ok := c.sweepPkScripts[chanID]; ok {
return nil
}
// Otherwise, generate a ne... | [
-1.1910607814788818,
0.057007331401109695,
0.37590184807777405,
-0.6587808728218079,
0.5884286165237427,
-0.08067522943019867,
-0.014832958579063416,
-0.3058142066001892,
0.8361706137657166,
-0.5755996108055115,
-0.27533209323883057,
0.7304425835609436,
-0.16611069440841675,
0.644325017929... |
func (c *TowerClient) BackupState(chanID *lnwire.ChannelID,
breachInfo *lnwallet.BreachRetribution) error {
// Retrieve the cached sweep pkscript used for this channel.
c.sweepPkScriptMu.RLock()
sweepPkScript, ok := c.sweepPkScripts[*chanID]
c.sweepPkScriptMu.RUnlock()
if !ok {
return ErrUnregisteredChannel
}... | [
-0.14026686549186707,
-0.4779127240180969,
0.429372102022171,
-0.4366118907928467,
0.0044075059704482555,
-0.19659991562366486,
0.15748193860054016,
0.024732327088713646,
0.8577354550361633,
-0.3763367533683777,
-0.8723675012588501,
-0.31396445631980896,
-0.29400143027305603,
0.28789874911... |
func (c *TowerClient) nextSessionQueue() *sessionQueue {
// Select any candidate session at random, and remove it from the set of
// candidate sessions.
var candidateSession *wtdb.ClientSession
for id, sessionInfo := range c.candidateSessions {
delete(c.candidateSessions, id)
// Skip any sessions with policies... | [
-0.149390310049057,
-1.6928695440292358,
0.5476743578910828,
0.38051924109458923,
-1.0371242761611938,
-0.4214842915534973,
0.2821704149246216,
-0.407460480928421,
1.1836036443710327,
0.27061042189598083,
-0.018104780465364456,
0.29684585332870483,
-0.8829774856567383,
-0.14809896051883698... |
func (c *TowerClient) backupDispatcher() {
defer c.wg.Done()
log.Tracef("Starting backup dispatcher")
defer log.Tracef("Stopping backup dispatcher")
for {
switch {
// No active session queue and no additional sessions.
case c.sessionQueue == nil && len(c.candidateSessions) == 0:
log.Infof("Requesting ne... | [
0.5097514390945435,
-1.241727590560913,
0.823107123374939,
0.19715015590190887,
-0.22758853435516357,
-0.8059267997741699,
1.149146318435669,
-0.8047601580619812,
0.888927161693573,
-0.19962681829929352,
-0.25823166966438293,
-0.3430219292640686,
0.21386335790157318,
0.15083305537700653,
... |
func (c *TowerClient) processTask(task *backupTask) {
status, accepted := c.sessionQueue.AcceptTask(task)
if accepted {
c.taskAccepted(task, status)
} else {
c.taskRejected(task, status)
}
} | [
-0.10121175646781921,
0.12827059626579285,
0.539056658744812,
0.16528168320655823,
-0.12650781869888306,
0.47955480217933655,
-0.015043606981635094,
0.18529854714870453,
0.5591405630111694,
0.6096504330635071,
-0.5761570930480957,
-0.06631553173065186,
0.19150514900684357,
0.90523695945739... |
func (c *TowerClient) taskAccepted(task *backupTask, newStatus reserveStatus) {
log.Infof("Backup chanid=%s commit-height=%d accepted successfully",
task.id.ChanID, task.id.CommitHeight)
c.stats.taskAccepted()
// If this task was accepted, we discard anything held in the prevTask.
// Either it was nil before, o... | [
0.49362531304359436,
-0.10337131470441818,
0.6285643577575684,
-0.4224693477153778,
-0.25142961740493774,
-0.3286575376987457,
0.8889976739883423,
0.31682318449020386,
0.438325434923172,
0.9367783069610596,
-1.1026108264923096,
-0.05964752286672592,
0.5634660720825195,
0.6556990742683411,
... |
func (c *TowerClient) taskRejected(task *backupTask, curStatus reserveStatus) {
switch curStatus {
// The sessionQueue has available capacity but the task was rejected,
// this indicates that the task was ineligible for backup.
case reserveAvailable:
c.stats.taskIneligible()
log.Infof("Backup chanid=%s commit... | [
0.26014935970306396,
0.2603027820587158,
0.6571701765060425,
-0.2681274116039276,
-0.4779234826564789,
-0.3238459825515747,
0.4954180419445038,
0.07955804467201233,
0.30382004380226135,
0.45554599165916443,
-0.9072802662849426,
0.10538087040185928,
-0.1432112157344818,
0.008440419100224972... |
func (c *TowerClient) dial(privKey *btcec.PrivateKey,
addr *lnwire.NetAddress) (wtserver.Peer, error) {
return c.cfg.AuthDial(privKey, addr, c.cfg.Dial)
} | [
-0.15374116599559784,
-0.24795137345790863,
0.25412270426750183,
-0.014329624362289906,
-0.47588682174682617,
0.7180821299552917,
-0.732056200504303,
0.05661941319704056,
0.4808639585971832,
0.7985120415687561,
0.5246114730834961,
1.3989322185516357,
-0.5403809547424316,
0.902126133441925,... |
func (c *TowerClient) readMessage(peer wtserver.Peer) (wtwire.Message, error) {
// Set a read timeout to ensure we drop the connection if nothing is
// received in a timely manner.
err := peer.SetReadDeadline(time.Now().Add(c.cfg.ReadTimeout))
if err != nil {
err = fmt.Errorf("unable to set read deadline: %v", er... | [
-0.15677446126937866,
0.18598490953445435,
0.5619834065437317,
-0.7140953540802002,
0.15729334950447083,
-0.48732635378837585,
-0.23463065922260284,
-0.3383027911186218,
-0.37365272641181946,
0.20270323753356934,
1.5135458707809448,
0.06508512794971466,
-1.396195650100708,
0.40010261535644... |
func (c *TowerClient) sendMessage(peer wtserver.Peer, msg wtwire.Message) error {
// Encode the next wire message into the buffer.
// TODO(conner): use buffer pool
var b bytes.Buffer
_, err := wtwire.WriteMessage(&b, msg, 0)
if err != nil {
err = fmt.Errorf("Unable to encode msg: %v", err)
log.Errorf("Unable t... | [
-0.5924515724182129,
0.454399049282074,
0.7432140111923218,
-0.4209679067134857,
0.47532978653907776,
0.015468096360564232,
0.25366711616516113,
0.09562777727842331,
-0.7776163220405579,
0.8036006689071655,
0.20765377581119537,
0.05779215320944786,
-1.5463879108428955,
0.7924607992172241,
... |
func (c *TowerClient) newSessionQueue(s *wtdb.ClientSession) *sessionQueue {
return newSessionQueue(&sessionQueueConfig{
ClientSession: s,
ChainHash: c.cfg.ChainHash,
Dial: c.dial,
ReadMessage: c.readMessage,
SendMessage: c.sendMessage,
Signer: c.cfg.Signer,
DB: c.cfg.D... | [
-0.1477091759443283,
-1.312996745109558,
0.45080405473709106,
0.2669874131679535,
-0.8550933599472046,
-0.5769782662391663,
-0.07808686047792435,
-0.8958672881126404,
0.6601297855377197,
0.8643854856491089,
-0.34424832463264465,
0.3959052860736847,
-0.29244309663772583,
0.590898334980011,
... |
func (c *TowerClient) getOrInitActiveQueue(s *wtdb.ClientSession) *sessionQueue {
if sq, ok := c.activeSessions[s.ID]; ok {
return sq
}
return c.initActiveQueue(s)
} | [
0.01947491616010666,
-1.900300145149231,
0.4686667025089264,
-0.35306617617607117,
-0.039827920496463776,
-0.6701313853263855,
0.416709303855896,
-0.4475042521953583,
1.0696594715118408,
0.14772439002990723,
0.35206088423728943,
0.22550153732299805,
-0.5773387551307678,
-0.1379764825105667... |
func (c *TowerClient) initActiveQueue(s *wtdb.ClientSession) *sessionQueue {
// Initialize the session queue, providing it with all of the resources
// it requires from the client instance.
sq := c.newSessionQueue(s)
// Add the session queue as an active session so that we remember to
// stop it on shutdown.
c.a... | [
0.20341312885284424,
-2.117288827896118,
0.5417620539665222,
-0.24758711457252502,
-0.48744064569473267,
-0.299933522939682,
0.4412117898464203,
0.20264185965061188,
0.35257211327552795,
-0.04530172422528267,
-0.754635751247406,
0.2622773349285126,
-0.23851120471954346,
0.02327161096036434... |
func logMessage(peer wtserver.Peer, msg wtwire.Message, read bool) {
var action = "Received"
var preposition = "from"
if !read {
action = "Sending"
preposition = "to"
}
summary := wtwire.MessageSummary(msg)
if len(summary) > 0 {
summary = "(" + summary + ")"
}
log.Debugf("%s %s%v %s %x@%s", action, msg.... | [
-0.673546314239502,
-0.136589914560318,
0.7418076395988464,
-1.3392988443374634,
0.04948076605796814,
0.08334628492593765,
-0.6198822855949402,
0.2692384719848633,
-0.02784563973546028,
0.02834814228117466,
0.48323777318000793,
0.29533863067626953,
-0.7303707599639893,
0.7278007864952087,
... |
func numJewelsInStones(J string, S string) int {
jm := make(map[rune]struct{})
for _, j := range J {
jm[j] = struct{}{}
}
ret := 0
for _, s := range S {
if _, exist := jm[s]; exist {
ret++
}
}
return ret
} | [
-0.028247931972146034,
-0.166829451918602,
0.5803040862083435,
-1.1357810497283936,
-1.0095769166946411,
-0.46141472458839417,
0.9284247756004333,
-0.3055897355079651,
-0.5627997517585754,
0.8855705857276917,
-0.716115415096283,
0.42392122745513916,
-0.5037120580673218,
0.3185018002986908,... |
func New(rootConfig *rootcmd.Config) *ffcli.Command {
fs := flag.NewFlagSet(CmdName, flag.ContinueOnError)
cfg := &Config{
rootConfig: rootConfig,
fs: fs,
}
cfg.registerFlags()
cmd := &ffcli.Command{
Name: CmdName,
ShortHelp: "list specific resources",
FlagSet: fs,
Exec: func(ctx contex... | [
0.28724268078804016,
-0.7581789493560791,
0.4023307263851166,
0.1146952211856842,
-0.07479706406593323,
-0.8203423023223877,
-0.3158658444881439,
-0.025567028671503067,
-0.08494732528924942,
-1.0565109252929688,
0.43333253264427185,
0.4613150954246521,
0.9268985390663147,
1.319719672203064... |
func (c *Config) ParseFile(filepath string) (err error) {
_, err = toml.DecodeFile(filepath, c)
return
} | [
0.2976979911327362,
0.7318974137306213,
0.10237030684947968,
-0.6124538779258728,
-0.22424888610839844,
0.22200974822044373,
0.5199406743049622,
0.6155997514724731,
-0.550147533416748,
0.2110428512096405,
-0.617000937461853,
-0.4419797956943512,
0.12211666256189346,
0.3845345377922058,
0... |
func (c *Config) ParseFiles(filepaths ...string) (err error) {
for _, f := range filepaths {
if err = c.ParseFile(f); err != nil {
return
}
}
return
} | [
-0.20428745448589325,
0.9013379812240601,
-0.0030889520421624184,
0.8117529153823853,
0.6270499229431152,
0.12593801319599152,
0.08005496859550476,
0.5377256870269775,
-1.1491488218307495,
-0.0433005690574646,
0.13596095144748688,
-1.0442416667938232,
-0.4674811363220215,
0.958219587802887... |
func Handler(c Config) (http.Handler, error) {
h, _, err := HandlerAPI(c)
return h, err
} | [
-0.3753024637699127,
-0.08202105760574341,
0.11460921913385391,
0.7589162588119507,
0.07470254600048065,
0.6204349398612976,
0.49485212564468384,
0.712897539138794,
0.0629936084151268,
-0.5129782557487488,
-1.0831433534622192,
-0.2739175856113434,
0.19189445674419403,
-0.22954024374485016,... |
func HandlerAPI(c Config) (http.Handler, *operations.Kube4EdgeManagementAPI, error) {
spec, err := loads.Analyzed(swaggerCopy(SwaggerJSON), "")
if err != nil {
return nil, nil, fmt.Errorf("analyze swagger: %v", err)
}
api := operations.NewKube4EdgeManagementAPI(spec)
api.ServeError = errors.ServeError
api.Logge... | [
-0.1659216582775116,
-0.27982744574546814,
0.7095506191253662,
0.20716075599193573,
-0.10328564047813416,
-0.5072463154792786,
0.9589856266975403,
-0.011135673150420189,
0.16581419110298157,
-0.26764753460884094,
0.28031834959983826,
-0.22290931642055511,
0.46595773100852966,
0.43730178475... |
func swaggerCopy(orig json.RawMessage) json.RawMessage {
c := make(json.RawMessage, len(orig))
copy(c, orig)
return c
} | [
-0.9417019486427307,
-0.7194778919219971,
0.47728845477104187,
-1.4030885696411133,
-1.7095222473144531,
-0.35042232275009155,
-0.20911099016666412,
-0.6718101501464844,
0.38954535126686096,
0.5970681309700012,
-0.5619940161705017,
0.20459671318531036,
-0.11123766750097275,
-1.164409399032... |
func Push(ctx context.Context, source string, destination string, options *PushOptions) error {
if options == nil {
options = new(PushOptions)
}
conn, err := bindings.GetClient(ctx)
if err != nil {
return err
}
header, err := auth.MakeXRegistryAuthHeader(&imageTypes.SystemContext{AuthFilePath: options.GetAuth... | [
-0.47757595777511597,
0.8617896437644958,
0.7504804134368896,
-0.14242926239967346,
-0.28352710604667664,
-0.7040122747421265,
0.09367088973522186,
-0.45707812905311584,
-0.16873645782470703,
1.1486257314682007,
-0.200208842754364,
0.8149163126945496,
0.47986900806427,
0.9014057517051697,
... |
func (c *Client) GetCredentials(ctx context.Context, params *GetCredentialsInput, optFns ...func(*Options)) (*GetCredentialsOutput, error) {
if params == nil {
params = &GetCredentialsInput{}
}
result, metadata, err := c.invokeOperation(ctx, "GetCredentials", params, optFns, c.addOperationGetCredentialsMiddleware... | [
-0.9273168444633484,
0.9347805380821228,
0.5252721905708313,
1.1906124353408813,
1.0518425703048706,
-0.7892723679542542,
0.48369234800338745,
-1.2134031057357788,
0.47329115867614746,
0.11402292549610138,
-0.5264637470245361,
1.226587176322937,
-0.576244592666626,
-0.37738853693008423,
... |
func (hook ContextHook) Levels() []logrus.Level {
return logrus.AllLevels
} | [
0.05926716700196266,
-0.5130895376205444,
0.32325243949890137,
0.42949897050857544,
1.0495193004608154,
0.9917829036712646,
-0.6191642880439758,
-0.08678992092609406,
0.13001473248004913,
-0.4140712320804596,
0.19268544018268585,
0.9109587669372559,
-0.4221319258213043,
0.856411874294281,
... |
func NewLogger(withContext bool) *logrus.Logger {
logger := logrus.New()
logrus.SetOutput(os.Stdout)
if withContext {
logger.AddHook(ContextHook{})
}
return logger
} | [
-0.08438055962324142,
-0.3061680197715759,
0.3991274833679199,
0.3700615465641022,
-1.2575594186782837,
-0.6394910216331482,
-0.5731685757637024,
0.3732664883136749,
0.44798848032951355,
-0.7074649930000305,
0.6931748390197754,
0.6477516889572144,
-0.5100304484367371,
0.9521579742431641,
... |
func Contains(haystack []string, needle string) bool {
for _, v := range haystack {
if v == needle {
return true
}
}
return false
} | [
0.4542255103588104,
-0.35189273953437805,
0.2544487714767456,
-0.17620427906513214,
0.1619301438331604,
-0.35671186447143555,
-1.2293781042099,
-0.1779678612947464,
-0.3284715414047241,
0.21207615733146667,
-0.20877018570899963,
1.0121787786483765,
-0.050362225621938705,
0.2351139783859253... |
func (hr *HTTPRequest) GetResponse(t *testing.T) *HTTPResponse {
select {
case resp := <-hr.ch:
return resp
case <-time.After(timeoutSeconds * time.Second):
if t == nil {
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
panic(fmt.Sprintf("expected a response to http request %#v, but found none", hr.req.URL.... | [
0.4061098098754883,
-0.2897465229034424,
0.5128765106201172,
0.5564804077148438,
1.13153076171875,
-0.5447283983230591,
0.1612391322851181,
-0.8890786170959473,
0.5482573509216309,
-0.3981930911540985,
0.8578790426254272,
-0.15955466032028198,
-0.5563544631004333,
-0.11378677934408188,
0... |
func (hr *HTTPResponse) Equals(t *testing.T, code int, body interface{}) *HTTPResponse {
hr.AssertStatusCode(t, code)
hr.AssertBody(t, body)
return hr
} | [
-0.44416457414627075,
-1.0573772192001343,
0.49295574426651,
-0.8181379437446594,
0.7341923117637634,
0.8241370320320129,
-0.4789017140865326,
-0.2593636214733124,
0.9488129615783691,
-0.4321121871471405,
-0.2932144105434418,
0.3969314694404602,
-0.9252636432647705,
0.0734424740076065,
0... |
func (hr *HTTPResponse) AssertStatusCode(t *testing.T, code int) *HTTPResponse {
if hr.Code != code {
t.Fatalf("expected response code to be %d, but got %d", code, hr.Code)
}
return hr
} | [
0.16692733764648438,
-0.5270814299583435,
0.04816047102212906,
-0.24589361250400543,
0.4878978133201599,
0.5756925940513611,
0.1345585435628891,
-0.16523945331573486,
1.270654320716858,
0.1816832572221756,
0.24863742291927338,
0.09149576723575592,
-0.7243132591247559,
0.5939927697181702,
... |
func (hr *HTTPResponse) AssertBody(t *testing.T, body interface{}) *HTTPResponse {
var err error
var bj []byte
// Check if we have an exact string
if bj, ok := body.([]byte); ok {
if strings.TrimSpace(hr.Body.String()) != string(bj) {
t.Fatalf("expected response body to be: \n%s\nbut got:\n%s", bj, hr.Body.St... | [
-0.02562885731458664,
-0.7489079236984253,
0.890098512172699,
-0.12011883407831192,
0.5947792530059814,
0.1870943307876587,
0.17567066848278046,
-1.0878691673278809,
1.3151097297668457,
0.021511083468794823,
0.48384493589401245,
0.44865092635154724,
-1.1029672622680664,
0.5498823523521423,... |
func (hr *HTTPResponse) AssertHeaders(t *testing.T, h map[string]string) *HTTPResponse {
for k, v := range h {
hv := hr.Result().Header.Get(k)
if hv != v {
if hv == "" {
t.Fatalf("expected response header %s to be %s, but header not found", k, v)
} else {
t.Fatalf("expected response header %s to be %... | [
-0.3356352150440216,
-0.9454162120819092,
0.24117843806743622,
-0.028320958837866783,
0.9838863611221313,
-0.0054444847628474236,
-0.4756212532520294,
-1.3012385368347168,
0.29596564173698425,
0.15286171436309814,
0.43085411190986633,
-0.7892570495605469,
-1.6827713251113892,
0.37404805421... |
func (hr *HTTPResponse) AssertMissingHeaders(t *testing.T, h []string) *HTTPResponse {
for _, h := range h {
hv := hr.Result().Header.Get(h)
if hv != "" {
t.Fatalf("expected response header %s to be missing, but got %s", h, hv)
}
}
return hr
} | [
-0.1610839068889618,
-0.7058490514755249,
0.3124472200870514,
-0.017501426860690117,
0.699653685092926,
0.16952171921730042,
-0.6613349318504333,
-1.0932120084762573,
-0.09994339197874069,
0.11634080857038498,
-0.1806221902370453,
-1.1021982431411743,
-1.4083855152130127,
0.774435877799987... |
func (pr *PathRange) BreadthFirstMapAt(p gruid.Point) int {
if !p.In(pr.Rg) || pr.BfMap == nil {
return pr.BfUnreachable
}
cost := pr.BfMap[pr.idx(p)]
if cost == 0 {
return pr.BfUnreachable
}
return cost - 1
} | [
-0.7845984697341919,
-0.4210681617259979,
0.6493980884552002,
0.07569748163223267,
-0.015044311061501503,
-0.07283276319503784,
0.36797356605529785,
0.04499930888414383,
0.5527942776679993,
-0.21772803366184235,
0.30857741832733154,
0.13382911682128906,
-0.6537061333656311,
-0.077683225274... |
func (pr *PathRange) BreadthFirstMap(nb Pather, sources []gruid.Point, maxCost int) []Node {
max := pr.Rg.Size()
w, h := max.X, max.Y
if pr.BfMap == nil {
pr.BfMap = make([]int, w*h)
pr.BfQueue = make([]Node, w*h)
} else {
for i := range pr.BfMap {
pr.BfMap[i] = 0
}
}
var qstart, qend int
pr.BfUnreach... | [
-0.6215783953666687,
-0.18220414221286774,
0.7805557250976562,
-0.15354609489440918,
0.38336488604545593,
-0.22519530355930328,
0.1195482611656189,
0.1359488070011139,
0.2698032259941101,
-0.021452609449625015,
0.21670940518379211,
0.23340925574302673,
-0.45822206139564514,
0.5658684372901... |
func (englishBot) getGreeting() string {
return "hello" //english specific
} | [
0.004805136937648058,
1.1205098628997803,
0.7103614807128906,
0.03649619221687317,
0.26795750856399536,
1.4235401153564453,
-1.4337037801742554,
-0.10524658113718033,
-1.176255464553833,
0.21351255476474762,
-0.4261207580566406,
-0.01507693063467741,
-0.20610249042510986,
0.380074501037597... |
func TestUpload(t *testing.T) {
oss := NewService("<<api key>>", "<<secret key>>")
oss.SetEndPoint("oss-cn-shanghai.aliyuncs.com")
oss.SetBucket("dong-feng")
opts1 := &UploadOptions{
ObjectName: "test",
Public: true,
IsFolder: true,
}
resp := oss.Upload(opts1)
if resp.Error != nil {
t.Error(resp.... | [
-0.5363825559616089,
0.9662990570068359,
0.901892364025116,
0.5916926264762878,
1.0154777765274048,
0.2953859865665436,
0.3544214963912964,
-0.7468528747558594,
-0.20981475710868835,
-0.49843892455101013,
-0.41099318861961365,
-0.03144633024930954,
-0.6623326539993286,
-0.18484187126159668... |
func (*Members) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*Members_Leader)(nil),
(*Members_Master)(nil),
(*Members_Worker)(nil),
}
} | [
-1.0326037406921387,
-0.04636118561029434,
0.3027438521385193,
-0.030009564012289047,
1.3563287258148193,
-0.10165225714445114,
-0.578520655632019,
-0.5707274675369263,
1.0718638896942139,
-0.07293002307415009,
-0.11763446778059006,
0.2867991626262665,
-0.8599520921707153,
0.64998316764831... |
func NewProjectService(gc GitlabClient) *ProjectService {
return &ProjectService{gitlabClient: gc}
} | [
0.625760555267334,
0.17001096904277802,
-0.1795521080493927,
0.007088327314704657,
-0.3040442168712616,
0.5317904353141785,
-0.7634138464927673,
-0.9399595260620117,
-0.5289546847343445,
0.3291093111038208,
-0.19655005633831024,
-0.03944195434451103,
-1.3571138381958008,
0.0616880357265472... |
func (projectService *ProjectService) GetAllProjects() (*[]model.Project, error) {
resp, err := projectService.gitlabClient("GET", "/projects", nil)
if err != nil {
return nil, err
}
// close the body after process is done
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
projectList := &[]model.Pro... | [
-0.16398166120052338,
0.4122757911682129,
0.28768783807754517,
0.6384515166282654,
0.7856830954551697,
0.4611760079860687,
-1.7136412858963013,
-0.13431784510612488,
0.2313784956932068,
0.006379248574376106,
-0.28450632095336914,
1.0122838020324707,
-1.305715560913086,
0.5367172956466675,
... |
func (projectService *ProjectService) GetProjectByID(projectID string) (*model.Project, error) {
resp, err := projectService.gitlabClient("GET", "/projects/"+projectID, nil)
if err != nil {
return nil, err
}
// close the body after process is done
defer resp.Body.Close()
dec := json.NewDecoder(resp.Body)
pr... | [
0.22746971249580383,
0.31764906644821167,
-0.1026528999209404,
-0.2869426906108856,
0.5241506695747375,
-0.042789094150066376,
-0.36660465598106384,
-1.1233488321304321,
-0.04422621428966522,
0.7371129393577576,
-0.2795489430427551,
-0.025047097355127335,
-1.0499826669692993,
0.06652891635... |
func padRight(str string, length int, pad string) string {
return str + times(pad, length-len(str))
} | [
0.7862475514411926,
0.40885645151138306,
0.6027536988258362,
-0.7936989068984985,
-1.0688056945800781,
0.8400075435638428,
-1.7975455522537231,
-0.8136278390884399,
0.21752633154392242,
-0.381332129240036,
0.29549410939216614,
0.6031935811042786,
-0.7443717122077942,
-0.46552568674087524,
... |
func (rf *Raft) GetState() (int, bool) {
var term int
// Your code here (2A).
rf.mu.Lock()
defer rf.mu.Unlock()
term = rf.currentTerm
return term, rf.state == Leader
} | [
-0.03071221522986889,
-0.3110709488391876,
0.6377032995223999,
0.7531749606132507,
-0.2800181210041046,
-0.6219822764396667,
0.6130361557006836,
-0.23024339973926544,
0.11580318957567215,
-0.11245520412921906,
-1.0568926334381104,
1.074327826499939,
-1.2611684799194336,
0.41673457622528076... |
func (rf *Raft) persist() {
// Your code here (2C).
// Example:
// w := new(bytes.Buffer)
// e := labgob.NewEncoder(w)
// e.Encode(rf.xxx)
// e.Encode(rf.yyy)
// data := w.Bytes()
// rf.persister.SaveRaftState(data)
w := new(bytes.Buffer)
e := labgob.NewEncoder(w)
e.Encode(rf.currentTerm)
e.Encode(rf.votedF... | [
0.06811992079019547,
-0.02220096066594124,
0.7479724287986755,
-0.06950919330120087,
0.3824264407157898,
0.4832165539264679,
0.5782573819160461,
-0.39538171887397766,
0.13839223980903625,
-0.6376751661300659,
-1.2007502317428589,
-0.25431931018829346,
-0.958823561668396,
0.5670908093452454... |
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)
// var xxx
// var yyy
// if d.Decode(&xxx) != nil ||
// d.Decode(&yyy) != nil {
// error.... | [
-0.4635082483291626,
-0.3463846743106842,
0.7811503410339355,
0.655264675617218,
0.006885129027068615,
-0.3745063543319702,
0.1572253555059433,
0.2474556714296341,
0.3507313132286072,
-0.537543773651123,
-0.15172983705997467,
-0.18203739821910858,
-0.7111834287643433,
0.3682814836502075,
... |
func (rf *Raft) RequestVote(args *RequestVoteArgs, reply *RequestVoteReply) {
// Your code here (2A, 2B).
//All Server rule
rf.mu.Lock()
defer rf.mu.Unlock()
if args.Term > rf.currentTerm {
rf.beFollower(args.Term)
// TODO check
// send(rf.voteCh)
}
reply.Term = rf.currentTerm
reply.VoteGranted = false
... | [
-0.049941204488277435,
-0.43996042013168335,
0.8344574570655823,
0.629903256893158,
0.31764283776283264,
0.28058773279190063,
-0.12996983528137207,
-0.10001391172409058,
0.00775262713432312,
0.16050520539283752,
0.09425819665193558,
0.8585588335990906,
-0.7673381567001343,
0.25766313076019... |
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) Start(command interface{}) (int, int, bool) {
rf.mu.Lock()
defer rf.mu.Unlock()
index := -1
term := rf.currentTerm
isLeader := rf.state == Leader
// Your code here (2B).
if isLeader {
DPrintf("i am leader %v, and i send command %v", rf.me, command)
index = rf.getLastLogIndex() + 1
newLog... | [
-0.5461614727973938,
-0.05162723362445831,
0.7522614002227783,
0.6074689626693726,
0.019741427153348923,
-0.12613116204738617,
0.3659609258174896,
-0.014495644718408585,
-0.19782747328281403,
0.49944740533828735,
-1.3895965814590454,
0.9822264909744263,
-0.6404300332069397,
0.1899167746305... |
func (rf *Raft) Kill() {
// Your code here, if desired.
send(rf.killCh)
} | [
0.3018157184123993,
0.06191030144691467,
0.3535263240337372,
1.9738802909851074,
0.7286183834075928,
0.17425648868083954,
0.647900402545929,
-0.07214713096618652,
-0.301754891872406,
-0.009834930300712585,
-0.6098068952560425,
0.7948155999183655,
-0.5030617713928223,
0.35189130902290344,
... |
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.state = Follower
rf.currentTerm = 0
rf.votedFor = NULL
rf.log = make([]Log, 1)
rf.commitInde... | [
0.12928707897663116,
-0.19371627271175385,
0.8941705822944641,
0.048638734966516495,
-0.34041884541511536,
-0.0995347797870636,
-0.136293426156044,
-0.4027281403541565,
0.17990745604038239,
-0.49838393926620483,
0.1910405308008194,
0.11944672465324402,
-0.32482993602752686,
0.1241848617792... |
func (_m *PrometheusBackend) SetMaxUnconfirmedAge(_a0 *big.Int, _a1 float64) {
_m.Called(_a0, _a1)
} | [
-0.4304214119911194,
0.19557273387908936,
0.23973576724529266,
-0.7536243200302124,
0.16136345267295837,
0.3990098834037781,
0.3233289122581482,
1.6153953075408936,
-0.3914033770561218,
0.8542786836624146,
0.4041890799999237,
0.3045344054698944,
0.9325360059738159,
1.2935047149658203,
0.... |
func (_m *PrometheusBackend) SetMaxUnconfirmedBlocks(_a0 *big.Int, _a1 int64) {
_m.Called(_a0, _a1)
} | [
-0.05675357207655907,
0.469430536031723,
0.26292872428894043,
-0.2974472641944885,
0.11405311524868011,
-0.00864249188452959,
0.561508297920227,
1.171249270439148,
-0.6761527061462402,
0.4840090274810791,
-0.2113955020904541,
0.7558554410934448,
0.6616138219833374,
1.090613603591919,
0.4... |
func (_m *PrometheusBackend) SetPipelineRunsQueued(n int) {
_m.Called(n)
} | [
-0.8228045701980591,
-0.1696641743183136,
0.12265573441982269,
-1.1367300748825073,
0.933904230594635,
-0.22207283973693848,
0.08582334965467453,
0.23823383450508118,
-1.2576239109039307,
-0.46395331621170044,
-1.0808595418930054,
0.4479961097240448,
0.7306479215621948,
0.4410499930381775,... |
func (_m *PrometheusBackend) SetPipelineTaskRunsQueued(n int) {
_m.Called(n)
} | [
-0.18664668500423431,
-0.0480332151055336,
0.28827208280563354,
-0.48205241560935974,
0.6875316500663757,
-0.18283499777317047,
0.3967909514904022,
0.562951385974884,
-1.2145248651504517,
-0.365587055683136,
-1.0080844163894653,
0.20128923654556274,
1.2030446529388428,
0.5944111943244934,
... |
func (_m *PrometheusBackend) SetUnconfirmedTransactions(_a0 *big.Int, _a1 int64) {
_m.Called(_a0, _a1)
} | [
-0.27318352460861206,
0.2483488768339157,
0.26434218883514404,
-1.0501883029937744,
0.3301202654838562,
-0.5999807119369507,
1.107776403427124,
0.47260886430740356,
-0.6792114973068237,
0.3645728528499603,
-0.5709409713745117,
-0.24330314993858337,
0.922141432762146,
0.7066911458969116,
... |
func (l ClientCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClientCreateOrUpdateResponse, error) {
respType := ClientCreateOrUpdateResponse{}
resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.ManagementGroup)
if err != nil {
return respType, err
}
respType.RawRes... | [
-0.7343543171882629,
0.545326292514801,
0.19233211874961853,
-0.20047897100448608,
0.2524111866950989,
0.8417539000511169,
0.011080261319875717,
-1.3743417263031006,
0.11521393060684204,
-0.05546106770634651,
0.09609797596931458,
-0.5788163542747498,
-0.9556651711463928,
0.9921790957450867... |
func (l *ClientCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *Client, token string) error {
pt, err := armruntime.NewPollerFromResumeToken("Client.CreateOrUpdate", token, client.pl)
if err != nil {
return err
}
poller := &ClientCreateOrUpdatePoller{
pt: pt,
}
resp, err := poller.Poll(ctx)
... | [
0.12969350814819336,
-0.29823610186576843,
0.3114890158176422,
-0.8364729881286621,
0.19281254708766937,
0.12919582426548004,
-0.06612257659435272,
-1.0100733041763306,
0.11806093156337738,
-0.48479393124580383,
-0.29933786392211914,
-0.16047006845474243,
-1.2073166370391846,
-0.3424534499... |
func (l ClientDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ClientDeleteResponse, error) {
respType := ClientDeleteResponse{}
resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.AzureAsyncOperationResults)
if err != nil {
return respType, err
}
respType.RawResponse = resp
... | [
-0.31803616881370544,
0.3584493100643158,
0.22855770587921143,
-0.490508109331131,
0.43742677569389343,
0.5331665873527527,
-0.043162427842617035,
-1.133824348449707,
0.5269108414649963,
0.5977928638458252,
0.59300297498703,
-0.4579951763153076,
-0.9844840168952942,
0.7654830813407898,
0... |
func (l *ClientDeletePollerResponse) Resume(ctx context.Context, client *Client, token string) error {
pt, err := armruntime.NewPollerFromResumeToken("Client.Delete", token, client.pl)
if err != nil {
return err
}
poller := &ClientDeletePoller{
pt: pt,
}
resp, err := poller.Poll(ctx)
if err != nil {
return... | [
0.8554064035415649,
-0.5156171321868896,
0.381883829832077,
-1.1155097484588623,
0.24119430780410767,
-0.18003784120082855,
-0.1757156103849411,
-0.4797445237636566,
0.4396776258945465,
-0.12924134731292725,
-0.14349870383739471,
0.3986174762248993,
-1.0296519994735718,
-0.9691261053085327... |
func NewCache() *Cache {
c := &Cache{}
c.entries = make(map[string]*entry)
c.mutex = &sync.Mutex{}
return c
} | [
0.43375054001808167,
-0.6745922565460205,
0.21925337612628937,
0.31236958503723145,
-0.8072235584259033,
-0.5643060803413391,
-0.015490022487938404,
-0.07722944021224976,
0.23240046203136444,
0.08148449659347534,
0.3452650308609009,
0.015569943934679031,
-0.4105754494667053,
-0.13580025732... |
func (cache *Cache) Get(key string) (val interface{}, found bool) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
entry := cache.entries[key]
if entry == nil {
return nil, false
} else if entry.expiration.Before(time.Now()) {
return nil, false
} else {
return entry.data, true
}
} | [
-0.6683385372161865,
0.2020629495382309,
0.7390015125274658,
-0.30150023102760315,
-0.5423996448516846,
-0.1171518862247467,
-1.1127914190292358,
0.08823283761739731,
-0.6317960619926453,
0.759421706199646,
-0.4064028859138489,
0.2856866121292114,
0.07775238901376724,
0.34863993525505066,
... |
func (cache *Cache) Set(key string, data interface{}, ttl time.Duration) {
cache.mutex.Lock()
defer cache.mutex.Unlock()
cache.entries[key] = &entry{data, time.Now().Add(ttl)}
} | [
-0.5999376773834229,
-0.024017056450247765,
0.11790551245212555,
-0.6463813185691833,
-0.255592405796051,
0.05306154116988182,
-1.1501145362854004,
0.22637325525283813,
-0.5433465838432312,
1.1627395153045654,
-0.6792053580284119,
0.39522436261177063,
0.5605476498603821,
0.5395019054412842... |
func ReplaceOutput(s string) string {
for _, f := range []func(string) string{
ResetDuration,
ReplaceAddr,
ReplaceUserAgent,
ReplaceDateHeader,
} {
s = f(s)
}
return s
} | [
0.23316127061843872,
-0.27985918521881104,
0.2885231673717499,
0.05510696768760681,
-0.3141953945159912,
-1.3955914974212646,
1.0399754047393799,
0.4504013657569885,
-0.3811754584312439,
-0.2090499997138977,
0.034120380878448486,
-0.45377805829048157,
-0.3006573021411896,
-0.04992771148681... |
func ResetDuration(s string) string {
s = dddPattern.ReplaceAllString(s, "0.00s")
s = ddddPattern.ReplaceAllString(s, "0.000s")
return elapsedTimePattern.ReplaceAllString(s, "elapsed time: 0.000000 sec")
} | [
-0.07279974222183228,
-0.3146737515926361,
0.509213924407959,
-0.390240877866745,
-0.14748166501522064,
0.15297861397266388,
0.7887957692146301,
0.952103853225708,
0.479842871427536,
0.8326192498207092,
-0.014271208085119724,
0.636376678943634,
0.6150657534599304,
-0.20470137894153595,
0... |
func ReplaceAddr(s string) string {
s = ipv4AddrPattern.ReplaceAllString(s, "127.0.0.1:12345")
return ipv6AddrPattern.ReplaceAllString(s, "[::]:12345")
} | [
0.47637128829956055,
-0.7998794317245483,
0.49651357531547546,
-1.3060545921325684,
-0.9091414213180542,
0.04586911201477051,
0.15626849234104156,
1.1711249351501465,
1.05059814453125,
-0.044712238013744354,
0.24483081698417664,
0.25333932042121887,
0.45935553312301636,
-0.2611508071422577... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.