text
stringlengths
11
6.3k
embedding
listlengths
768
768
func NewQueue(maximumCapacity int, initialCapacity int, factory TokenFactory) *Queue { q := &Queue{ maxCapacity: maximumCapacity, availableTokens: make(chan (Token), maximumCapacity), committedTokens: make(chan (Token), maximumCapacity), discardTokens: make(chan (Token), maximumCapacity), closeTokens: ...
[ 0.4267396926879883, -0.6505717635154724, 0.4988062083721161, 0.21570459008216858, -0.49052268266677856, -1.0396604537963867, -0.7836827039718628, 0.3230276107788086, 0.0965682864189148, -0.47139713168144226, 0.010602823458611965, 0.8066074252128601, 0.18035942316055298, -0.1327237039804458...
func (q *Queue) GetAvailableToken(ctx context.Context) (Token, error) { for { token, err := q.tokenFromChannel(ctx, q.availableTokens) if err != nil { return token, err } /* Check if tokens need to be removed from circulation */ q.Lock() if q.currentCapacity > q.targetCapacity { q.discardTokens <- ...
[ -0.0865132138133049, -1.183161973953247, 0.5143256783485413, -0.6646062135696411, 0.3730534613132477, 0.02431510202586651, -0.3708055019378662, 0.6149261593818665, 0.15591196715831757, -0.03981499746441841, 0.3697943687438965, 1.4538406133651733, -0.559337317943573, -0.024549901485443115, ...
func (q *Queue) GetCommittedToken(ctx context.Context) (Token, error) { return q.tokenFromChannel(ctx, q.committedTokens) }
[ 0.6434230804443359, -1.1642286777496338, 0.35487738251686096, -0.06055060029029846, 0.3113081455230713, 0.7329497337341309, -0.28342321515083313, 0.47775930166244507, 0.01692277565598488, -0.43926987051963806, -0.22087596356868744, 1.2842222452163696, -0.528372585773468, -0.008483106270432...
func (q *Queue) GetAvailableTokenChan(ctx context.Context) <-chan (Token) { return q.getChannelReader(ctx, q.GetAvailableToken) }
[ -0.17258033156394958, -1.0071128606796265, 0.2841780185699463, -1.0384151935577393, -0.11254581063985825, 0.34648576378822327, -0.7260624766349792, -0.6448123455047607, -0.06872206181287766, -0.1634282022714615, 0.12547889351844788, 1.828198790550232, -0.04858070984482765, -0.2035807520151...
func (q *Queue) GetCommittedTokenChan(ctx context.Context) <-chan (Token) { return q.getChannelReader(ctx, q.GetCommittedToken) }
[ 0.2908349931240082, -1.2185914516448975, 0.37702926993370056, -0.78031986951828, 0.4273122549057007, 0.6460012197494507, -0.19934681057929993, -0.6721128225326538, 0.21733024716377258, -0.5020108222961426, 0.48666948080062866, 1.4381964206695557, -0.6749260425567627, 0.2071431577205658, ...
func (q *Queue) CommitToken(t Token) error { return q.tokenToChannel(q.committedTokens, t) }
[ -0.7197061777114868, -0.5445059537887573, 0.48788321018218994, -1.0767920017242432, 1.1605565547943115, 0.7382166385650635, -0.3097720146179199, 0.30448758602142334, -0.7756308913230896, 0.7504407167434692, -0.999179482460022, 0.8974181413650513, -0.09079137444496155, 0.561724066734314, ...
func (q *Queue) ReleaseToken(t Token) error { return q.tokenToChannel(q.availableTokens, t) }
[ -0.6173387765884399, 0.15528617799282074, 0.34496426582336426, -1.574318289756775, 0.21511095762252808, -0.26136040687561035, -0.9612405300140381, -0.021615512669086456, -0.5200745463371277, 0.2370089888572693, -1.569158673286438, 0.87953782081604, 0.5230790376663208, 0.39363253116607666, ...
func (q *Queue) Close() { q.Lock() closed := q.closed q.closed = true q.Unlock() if closed { return } capacityRemaining := q.maxCapacity /* Discard all tokens stuck in channel readers */ go func() { for { t, ok := <-q.closeTokens if !ok { return } q.discardTokens <- t } }() /* Drain...
[ 0.18832439184188843, -1.1030194759368896, 0.762001633644104, -1.1982128620147705, 0.3470000624656677, -0.007990752346813679, 0.010715430602431297, -0.24104684591293335, -0.6217131018638611, -0.46639591455459595, 0.7865614891052246, -0.04041556268930435, -1.2565637826919556, 0.4806015789508...
func (q *Queue) EnableDisableTokens(amount int) bool { q.Lock() defer q.Unlock() if q.closed { return false } if amount > q.maxCapacity || amount < 0 { return false } q.targetCapacity = amount /* If needed, make more available, so move n tokens from discard to available */ for q.currentCapacity < q.tar...
[ 0.20863080024719238, -0.3053864538669586, 0.7721470594406128, -1.0018342733383179, -0.2152787297964096, 0.35930758714675903, -0.5593718886375427, 0.575091540813446, 0.3482442796230316, -0.17209962010383606, -0.8878616094589233, -0.008165248669683933, -0.7279611229896545, 0.0002169609069824...
func (sender *Sender) Init(senderSettings interface{}, logger moira.Logger, location *time.Location, dateTimeFormat string) error { var victorops victorOps err := mapstructure.Decode(senderSettings, &victorops) if err != nil { return fmt.Errorf("failed to decode senderSettings to victorops config: %w", err) } se...
[ -0.39999115467071533, -0.6866552233695984, 0.5701383352279663, -0.3054180145263672, -0.1479901224374771, -0.7117443084716797, 0.026716599240899086, 0.663673996925354, 0.20968054234981537, 0.3204917907714844, -0.24635933339595795, 0.47037386894226074, 0.3215301036834717, 0.63853919506073, ...
func (c *S3Configuration) Credentials(accessKey, secretKey string) *S3Configuration { c.accessKey = accessKey c.secretKey = secretKey return c }
[ 0.6261566281318665, -1.0376847982406616, 0.3661545515060425, -0.13142019510269165, -0.08939596265554428, 0.7422729134559631, -0.8082724213600159, 0.966189444065094, 0.6056361794471741, -0.47733449935913086, -0.49115118384361267, 0.20306140184402466, 0.17230403423309326, -0.665678858757019,...
func Open(path string) (readerutil.ReaderAtCloser, error) { openFileMu.Lock() of := openFiles[path] if of != nil { of.refCount++ openFileMu.Unlock() return &openFileHandle{false, of}, nil } openFileMu.Unlock() // release the lock while we call os.Open winner := false // this goroutine made it into Do's fun...
[ -1.001436710357666, -0.35632428526878357, 0.6235330104827881, 0.09865935891866684, -0.9473649859428406, -0.08375965803861618, 1.0770031213760376, -0.3883797526359558, 0.12352035939693451, -0.7714797258377075, 0.9065793752670288, -0.5086341500282288, -0.6921249628067017, -0.2109744548797607...
func (s AssociateWebACLInput) String() string { return awsutil.Prettify(s) }
[ 0.5634369850158691, -0.20874738693237305, 0.07942559570074081, -0.7621943950653076, -0.11064803600311279, 0.8178202509880066, 1.3495042324066162, -1.4026329517364502, 0.3112468719482422, -0.17116490006446838, 0.2632262706756592, 1.4019291400909424, 0.6109907031059265, 0.2487988919019699, ...
func (s *AssociateWebACLInput) Validate() error { invalidParams := aws.ErrInvalidParams{Context: "AssociateWebACLInput"} if s.ResourceArn == nil { invalidParams.Add(aws.NewErrParamRequired("ResourceArn")) } if s.ResourceArn != nil && len(*s.ResourceArn) < 1 { invalidParams.Add(aws.NewErrParamMinLen("ResourceAr...
[ -0.21449965238571167, -0.49807649850845337, 0.2398877590894699, -0.16032865643501282, 0.5040287375450134, -0.056569505482912064, 0.8081624507904053, -0.6706123352050781, -0.004592875484377146, -0.19381801784038544, 0.5793646574020386, 0.9470321536064148, 0.009461750276386738, 1.56649267673...
func (s AssociateWebACLOutput) String() string { return awsutil.Prettify(s) }
[ 1.4078890085220337, -0.5123454332351685, 0.1607859879732132, -0.5881271362304688, -0.7351073026657104, -0.13727544248104095, 1.4636646509170532, -1.0906634330749512, -0.14716482162475586, -0.18487529456615448, 0.5715683698654175, 0.9786125421524048, 0.8882594108581543, 0.16415293514728546,...
func (r AssociateWebACLRequest) Send(ctx context.Context) (*AssociateWebACLResponse, error) { r.Request.SetContext(ctx) err := r.Request.Send() if err != nil { return nil, err } resp := &AssociateWebACLResponse{ AssociateWebACLOutput: r.Request.Data.(*AssociateWebACLOutput), response: &aws.Resp...
[ -0.5387927889823914, -0.5040075778961182, 0.2858738899230957, 0.024576136842370033, 0.45165643095970154, -0.3280683755874634, 0.7803494930267334, -1.2637253999710083, 0.4834417402744293, -0.11087754368782043, -0.1699550747871399, 1.2063204050064087, 0.055834606289863586, 0.5988452434539795...
func (r *AssociateWebACLResponse) SDKResponseMetdata() *aws.Response { return r.response }
[ 0.5432177186012268, -0.6358740329742432, 0.21567629277706146, -0.5992147326469421, 0.14443030953407288, 0.06490602344274521, 0.04130297154188156, -0.7286021113395691, 1.107740044593811, -0.17951665818691254, -0.21911950409412384, 0.36757397651672363, 0.5881706476211548, -0.3227843642234802...
func NewPostAdminUsersParams() *PostAdminUsersParams { var () return &PostAdminUsersParams{ timeout: cr.DefaultTimeout, } }
[ 0.43551746010780334, -0.061424195766448975, -0.2798953652381897, 0.4540000855922699, -1.4620047807693481, 0.7892890572547913, -0.5605018734931946, -0.4594167172908783, -1.0885157585144043, 0.16823452711105347, -0.5558959245681763, 0.9093485474586487, -1.5331718921661377, 0.9228111505508423...
func NewPostAdminUsersParamsWithTimeout(timeout time.Duration) *PostAdminUsersParams { var () return &PostAdminUsersParams{ timeout: timeout, } }
[ 0.6672946214675903, -0.18451867997646332, -0.0978001281619072, 0.3780277967453003, -1.4859037399291992, 1.2871521711349487, -1.381042718887329, -0.5394728183746338, -0.8706342577934265, 0.8195090889930725, -0.13574440777301788, 0.9508362412452698, -1.147131085395813, 0.9313027858734131, ...
func NewPostAdminUsersParamsWithContext(ctx context.Context) *PostAdminUsersParams { var () return &PostAdminUsersParams{ Context: ctx, } }
[ 0.2423771470785141, -0.05644065514206886, 0.05151106417179108, -0.16869476437568665, -1.3985382318496704, 1.2268602848052979, -1.3653364181518555, -1.115140676498413, -0.382417231798172, 0.33604076504707336, -0.2675628364086151, 0.6552816033363342, -1.267043948173523, 0.5517815947532654, ...
func NewPostAdminUsersParamsWithHTTPClient(client *http.Client) *PostAdminUsersParams { var () return &PostAdminUsersParams{ HTTPClient: client, } }
[ 0.10900575667619705, -0.37441813945770264, -0.13555987179279327, -0.2896106541156769, -1.2075893878936768, 1.1603295803070068, -0.7438949346542358, -0.9971951842308044, -1.1476871967315674, 0.07187316566705704, -0.4575040936470032, 0.6434145569801331, -1.1389297246932983, 0.468945562839508...
func (o *PostAdminUsersParams) WithTimeout(timeout time.Duration) *PostAdminUsersParams { o.SetTimeout(timeout) return o }
[ 0.19355665147304535, 0.17043207585811615, -0.1082557961344719, 0.11564289033412933, -0.9727414846420288, 0.7997636198997498, -0.7639371156692505, -0.6866673231124878, -0.43141910433769226, 0.7662222981452942, 0.011042260564863682, 0.9602978229522705, -0.5215587019920349, 1.1816350221633911...
func (o *PostAdminUsersParams) SetTimeout(timeout time.Duration) { o.timeout = timeout }
[ -0.037999432533979416, 0.26081687211990356, -0.07478556036949158, 0.2658093273639679, -0.7742771506309509, 1.2364068031311035, -0.5555408596992493, -0.36545270681381226, -0.9125699400901794, 0.599129319190979, -0.19984346628189087, 1.0539602041244507, -1.201207160949707, 1.31537663936615, ...
func (o *PostAdminUsersParams) WithContext(ctx context.Context) *PostAdminUsersParams { o.SetContext(ctx) return o }
[ -0.5754662752151489, 0.2495010793209076, 0.17808060348033905, -0.04809543117880821, -1.0859756469726562, 0.6628424525260925, -0.9375837445259094, -1.095921277999878, -0.18780721724033356, 0.33484673500061035, -0.047366898506879807, 0.8831015229225159, -1.1554995775222778, 0.548609673976898...
func (o *PostAdminUsersParams) SetContext(ctx context.Context) { o.Context = ctx }
[ -0.5055009722709656, 0.5122498869895935, -0.0008133193477988243, 0.34127941727638245, -0.7154679894447327, 1.0125117301940918, -0.6147468686103821, -0.947492241859436, -0.16334272921085358, 0.04314664378762245, -0.46632662415504456, 0.9557904005050659, -1.6055397987365723, 0.69459474086761...
func (o *PostAdminUsersParams) WithHTTPClient(client *http.Client) *PostAdminUsersParams { o.SetHTTPClient(client) return o }
[ -0.320157915353775, -0.5604851841926575, 0.08537570387125015, -0.3608032166957855, -0.8950849771499634, 0.5255718231201172, -0.3254178762435913, -0.9877880811691284, -0.8687763214111328, 0.0783301293849945, -0.2535954713821411, 0.6617531180381775, -0.5495424866676331, 0.31922170519828796, ...
func (o *PostAdminUsersParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client }
[ 0.04387378692626953, -0.27686193585395813, 0.0011672161053866148, -0.6466346979141235, -0.9173843860626221, 0.6324057579040527, -0.2036825716495514, -0.7822775840759277, -1.5867244005203247, 0.013454783707857132, -0.6388729810714722, 1.10810387134552, -1.4486042261123657, 0.247903317213058...
func (o *PostAdminUsersParams) WithGroups(groups *string) *PostAdminUsersParams { o.SetGroups(groups) return o }
[ -0.6167208552360535, 0.6423014998435974, -0.389773428440094, -0.0868053212761879, -0.8208082318305969, 0.15235114097595215, -0.1696845144033432, -1.458309531211853, -0.6235525608062744, -0.250265508890152, 0.13474924862384796, 0.26860344409942627, -1.3516411781311035, 0.37944409251213074, ...
func (o *PostAdminUsersParams) SetGroups(groups *string) { o.Groups = groups }
[ -0.8096640706062317, 0.8288975954055786, -0.3489568829536438, 0.13040903210639954, -0.5683822631835938, 0.669365644454956, -0.21572427451610565, -1.0682607889175415, -1.08696711063385, -0.3416820764541626, -0.6282954216003418, 0.6099063158035278, -1.9299817085266113, 0.7900567054748535, ...
func (o *PostAdminUsersParams) WithPassword(password string) *PostAdminUsersParams { o.SetPassword(password) return o }
[ -0.20736318826675415, -0.023372838273644447, -0.011775406077504158, 0.2997787594795227, -0.8345181941986084, 0.41665229201316833, -0.27923494577407837, -0.7165065407752991, -0.5248165130615234, 0.18493574857711792, -0.3342389762401581, 0.11653386056423187, -0.9771606922149658, 0.7194752097...
func (o *PostAdminUsersParams) SetPassword(password string) { o.Password = password }
[ -0.22484435141086578, 0.03598982095718384, 0.004547043703496456, 0.6710184812545776, -0.7467336654663086, 0.7530020475387573, -0.11275053769350052, -0.31743326783180237, -1.0046430826187134, -0.07246269285678864, -0.7130641937255859, 0.6283051371574402, -1.8037610054016113, 1.2477775812149...
func (o *PostAdminUsersParams) WithUsername(username string) *PostAdminUsersParams { o.SetUsername(username) return o }
[ -0.6550068259239197, -0.08505623787641525, -0.009638038463890553, 0.01462124940007925, -0.9592912793159485, 0.08228731155395508, -0.05991654470562935, -0.5121626853942871, -0.9401969313621521, 0.3594679832458496, -0.6034874320030212, -0.02735416404902935, -1.4336551427841187, 0.83869838714...
func (o *PostAdminUsersParams) SetUsername(username string) { o.Username = username }
[ -0.8798661231994629, 0.0008008603472262621, -0.07778670638799667, 0.449365496635437, -0.8248183131217957, 0.45313966274261475, -0.03346171975135803, -0.23756015300750732, -1.1815900802612305, 0.01551300659775734, -0.9490510821342468, 0.2605758011341095, -1.880126953125, 1.231148362159729, ...
func (o *PostAdminUsersParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { if err := r.SetTimeout(o.timeout); err != nil { return err } var res []error if o.Groups != nil { // form param groups var frGroups string if o.Groups != nil { frGroups = *o.Groups } fGroups := frGr...
[ -1.0873392820358276, -0.2977815270423889, 0.8901312947273254, -0.34001871943473816, 0.09987389296293259, -0.08247750252485275, 0.6063432693481445, -0.44276857376098633, -1.0976184606552124, 0.08857859671115875, -0.04241814836859703, 0.26743531227111816, -0.8974031209945679, 0.7563398480415...
func RenderTotalSupplyObject(state interfaces.ChainStateOperationRead, totalsupply *stores.TotalSupply, isformatstring bool) (map[string]interface{}, map[string]string) { var ifs = isformatstring var object = make(map[string]interface{}) var objstr = make(map[string]string) // Status statistics appendToUint64(obj...
[ -0.2539007365703583, -0.4865000545978546, 0.8043633699417114, -0.9147675633430481, -0.5515926480293274, -0.2994314432144165, 0.12575583159923553, -0.5966265797615051, 0.5575807094573975, 0.37237492203712463, 0.3338428735733032, -0.06432457268238068, 0.3891427218914032, 0.190089613199234, ...
func (client Client) executeJsonRequest(href, httpMethod string, inputStructure any, errorMessage string) (*http.Response, error) { text, err := json.MarshalIndent(inputStructure, " ", " ") if err != nil { return nil, err } requestHref, err := url.Parse(href) if err != nil { return nil, err } var resp *htt...
[ -0.7946667671203613, -0.6759598851203918, 1.0777775049209595, -0.7673587799072266, -0.46748194098472595, -0.7541612386703491, -0.0029387339018285275, -0.6842957139015198, 0.3387058675289154, 0.8249205350875854, 0.4147655665874481, 0.3724672496318817, -0.23271845281124115, -0.22323414683341...
func closeBody(resp *http.Response) { err := resp.Body.Close() if err != nil { util.Logger.Printf("error closing response body - Called by %s: %s\n", util.CallFuncName(), err) } }
[ -0.027706053107976913, -0.8570489287376404, 0.3822696805000305, 0.23609265685081482, 0.24516239762306213, 0.32585573196411133, 0.16011996567249298, -0.9266507029533386, 1.0343096256256104, -0.388324499130249, -0.03803475946187973, -0.582845151424408, -0.05026097595691681, 0.648555338382721...
func parseCliArgs() (string, bool) { // parse config file location from command line flag configFilePath := flag.String("config", "/etc/oneill/config.yaml", "location of the oneill config file") showVersion := flag.Bool("v", false, "show version details and exit") flag.Parse() return *configFilePath, *showVersio...
[ -0.7801141738891602, -0.24143454432487488, 0.5373050570487976, -0.8941248655319214, -0.031761471182107925, 0.2372160106897354, 0.42432495951652527, 0.5131399631500244, -0.9048940539360046, 1.4228472709655762, -0.8675453662872314, -0.282387375831604, -0.7898449301719666, 0.46714115142822266...
func NewEndpointResource(communicationStyle string) *EndpointResource { return &EndpointResource{ CommunicationStyle: communicationStyle, Resource: *resources.NewResource(), } }
[ 0.10333242267370224, -0.5289574861526489, 0.09588448703289032, 0.3371545672416687, -1.2476720809936523, 0.045981042087078094, -0.9035370349884033, 0.6052536964416504, 0.49627768993377686, 0.7830106616020203, -0.03618679940700531, -0.5007433891296387, -1.7646033763885498, -0.351291626691818...
func (e *EndpointResource) GetCommunicationStyle() string { return e.CommunicationStyle }
[ 0.4626174569129944, -0.18059052526950836, 0.08620154112577438, 0.04121118038892746, -0.014689366333186626, 0.005366226192563772, -0.8139861822128296, 0.011039672419428825, -0.6179570555686951, 0.7533514499664307, 1.2610305547714233, -0.2223707139492035, -1.7807930707931519, -0.617132425308...
func (e EndpointResource) Validate() error { return validator.New().Struct(e) }
[ -0.4198518395423889, 0.06357458978891373, 0.25042667984962463, -0.04424929618835449, 0.26094257831573486, 0.5968248844146729, -0.32103875279426575, 0.2398664653301239, -0.6136904358863831, 0.06278140097856522, 0.6051010489463806, -1.0822200775146484, -0.7212361693382263, -0.099192120134830...
func (*SourceContext) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _SourceContext_OneofMarshaler, _SourceContext_OneofUnmarshaler, _SourceContext_OneofSizer, []interface{...
[ -0.7261106967926025, 0.9289829730987549, 0.4510648250579834, -0.9015030264854431, 0.38831186294555664, -0.6551385521888733, 0.5006869435310364, -1.3367903232574463, 0.8747245073318481, -0.27350085973739624, -0.8042675852775574, -0.27895236015319824, -0.3079691529273987, 1.0573245286941528,...
func (*CloudRepoSourceContext) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _CloudRepoSourceContext_OneofMarshaler, _CloudRepoSourceContext_OneofUnmarshaler, _CloudRepoSo...
[ -0.17366966605186462, 0.8919425010681152, 0.38740748167037964, -1.597184419631958, 0.6577112078666687, -0.489236444234848, 0.6870232224464417, -0.5801852345466614, 0.22203989326953888, -0.44116631150245667, -0.6995086669921875, -0.9195016026496887, -0.17608937621116638, 0.5735154151916504,...
func (*GerritSourceContext) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _GerritSourceContext_OneofMarshaler, _GerritSourceContext_OneofUnmarshaler, _GerritSourceContext_...
[ -0.21175536513328552, 0.8428673148155212, 0.5233650207519531, -1.3595397472381592, 0.5009394884109497, -0.4565122723579407, 0.6211667656898499, -0.9447036981582642, 0.8284100890159607, -0.29231706261634827, -0.7141315340995789, -0.5991249084472656, -0.2569515109062195, 0.7421084642410278, ...
func (*RepoId) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _RepoId_OneofMarshaler, _RepoId_OneofUnmarshaler, _RepoId_OneofSizer, []interface{}{ (*RepoId_ProjectRepoId)...
[ -0.5825487971305847, 0.7619447708129883, 0.4310414493083954, -0.896216869354248, 0.8594425916671753, -0.5854363441467285, 0.7996614575386047, -0.8883693814277649, 0.27794644236564636, -0.2154408097267151, -0.3988947868347168, -0.015097557567059994, -0.21901603043079376, 0.5599030256271362,...
func (b *Backend) Addr() net.Addr { return b.addr }
[ 0.6995421648025513, -0.1383097767829895, 0.3831647038459778, 0.9041880965232849, 0.022471226751804352, 0.8190725445747375, -0.11263230443000793, 0.12534746527671814, 0.32521429657936096, -0.4684171676635742, 1.0369163751602173, 0.5074900984764099, -0.5377283096313477, 0.06525231897830963, ...
func (b *Backend) AssignTier(latency time.Duration, tier int) { b.mu.Lock() b.mu.lastLatency = latency b.mu.tier = tier b.mu.Unlock() }
[ -0.05016621947288513, -0.731519877910614, 0.36846402287483215, -0.2626727521419525, 0.36613184213638306, -0.4919557571411133, -0.9176994562149048, 0.47125065326690674, -0.6799361705780029, 0.6606313586235046, -0.29628315567970276, 0.6534569263458252, -1.358884334564209, 0.4359748363494873,...
func (b *Backend) Disable() { b.mu.Lock() when := time.Now().Add(b.mu.disableDuration) b.mu.disabledUntil = when b.mu.Unlock() log.Printf("disabling %s until %s", b.addr, when) }
[ 0.8049168586730957, 0.5636109709739685, 0.33066317439079285, 0.7585801482200623, 0.14376147091388702, 0.37840428948402405, -0.06306813657283783, 1.3081380128860474, -0.6283314228057861, 0.27198585867881775, -0.21809814870357513, 0.7800089716911316, -1.4025650024414062, -0.3260655403137207,...
func (b *Backend) ForcePromotionAfter() time.Duration { b.mu.RLock() ret := b.mu.forcePromotionAfter b.mu.RUnlock() return ret }
[ -0.20600220561027527, 0.3428399860858917, 0.39247098565101624, 1.3055404424667358, 0.12170347571372986, 0.18928267061710358, -0.4484851062297821, -0.34924599528312683, -0.3203869163990021, -0.040423840284347534, -0.16592809557914734, 0.46898120641708374, -1.442975640296936, 0.2961095273494...
func (b *Backend) MaxLoad() int { b.mu.RLock() defer b.mu.RUnlock() if time.Now().Before(b.mu.disabledUntil) { return 0 } return b.mu.maxConnections }
[ -0.12258121371269226, 0.8142536282539368, 0.7701791524887085, 0.2232031226158142, -0.6137612462043762, -0.20363140106201172, -1.1698495149612427, 0.030992502346634865, 0.10814660042524338, -0.07542750984430313, 0.6384660005569458, -0.39383184909820557, -1.7831635475158691, 0.13528096675872...
func (b *Backend) MarshalYAML() (interface{}, error) { b.mu.RLock() defer b.mu.RUnlock() payload := struct { Address string DisabledUntil time.Time `yaml:"disabledUntil"` ForcePromotionsAfter time.Duration `yaml:"forcePromotionsAfter"` Latency time.Duration `yaml:"latenc...
[ 0.5398904085159302, 0.18745636940002441, 0.5364086031913757, 0.04085998609662056, -0.2870435416698456, -0.33125120401382446, -0.3518330156803131, 0.7654516696929932, -0.09940733015537262, 0.4041023552417755, -0.08815808594226837, 0.9477716684341431, -0.22176378965377808, -0.149833038449287...
func (b *Backend) Tier() int { b.mu.RLock() ret := b.mu.tier b.mu.RUnlock() return ret }
[ -0.31144407391548157, 0.2627578377723694, 0.5182051062583923, 0.4088263213634491, -0.32111984491348267, -0.5910824537277222, 0.3198656737804413, 0.2746446132659912, -1.480358362197876, -0.5425553321838379, -0.16347000002861023, 0.25985056161880493, -2.038727283477783, -0.3138108253479004, ...
func ConfirmDelete(frame chronolib.Frame) bool { reader := bufio.NewReader(os.Stdin) fmt.Printf(chronolib.FormatFrameDelete(frame)) text, _ := reader.ReadString('\n') text = strings.ToLower(strings.Replace(text, "\n", "", -1)) return text == "y" }
[ 0.2978605031967163, -0.18644703924655914, 0.7226044535636902, 0.6302419304847717, -0.11729844659566879, -0.15582557022571564, -0.23335042595863342, -0.3904549181461334, 0.30098748207092285, 0.19141553342342377, -0.005145578179508448, 0.3790905773639679, -0.8120803236961365, 0.6717742085456...
func NewOptions(chanOpts *tchannel.ChannelOptions) Options { return &options{ channelOptions: chanOpts, tchanChannelFn: defaultTChanChannelFn, tchanNodeServerFn: defaultTChanNodeServerFn, } }
[ 0.3838818371295929, -0.042937587946653366, 0.1840832382440567, -0.8426148295402527, 0.57806396484375, -0.9988585114479065, -0.4757590591907501, -0.8279586434364319, 0.507559061050415, -0.416915625333786, -0.35139787197113037, 0.3772415518760681, -0.43797457218170166, 0.5536036491394043, ...
func (splitter *OutputSplitter) Write(p []byte) (n int, err error) { if bytes.Contains(p, []byte("level=debug")) || bytes.Contains(p, []byte("level=info")) || bytes.Contains(p, []byte("level=trace")) || bytes.Contains(p, []byte("level=warn")) { return os.Stdout.Write(p) } return os.Stderr.Write(p) }
[ -1.0580668449401855, 0.24784450232982635, 0.7442929744720459, 0.24171513319015503, 0.008415253832936287, -0.32696011662483215, -0.011911416426301003, -0.04076883941888809, -0.10658430308103561, 0.20205555856227875, -0.2116256058216095, -0.4913846552371979, -1.2385677099227905, 0.4746691584...
func Blind(key *rsa.PublicKey, data []byte) ([]byte, []byte) { defer rsaTimeInc(time.Now()) blinded, bfactor, err := blind(rng, key, new(big.Int).SetBytes(data)) util.CheckErr(err) b, bf := blinded.Bytes(), bfactor.Bytes() return b, bf }
[ -0.6304752826690674, -0.43307173252105713, 0.546800434589386, 0.006867936346679926, -0.6763665080070496, 0.6175927519798279, -0.7830809354782104, -0.1145300343632698, 0.6379603147506714, 0.30481740832328796, -0.5530568361282349, 1.0266497135162354, -1.3199577331542969, 0.6574472784996033, ...
func Unblind(key *rsa.PublicKey, blindedSig, bfactor []byte) []byte { defer rsaTimeInc(time.Now()) m := new(big.Int).SetBytes(blindedSig) bfactorBig := new(big.Int).SetBytes(bfactor) m.Mul(m, bfactorBig) m.Mod(m, key.N) b := m.Bytes() return b }
[ -0.40813103318214417, -0.08661985397338867, 0.6390177011489868, -0.37277886271476746, -0.5428435802459717, -0.6959745287895203, 0.2320072501897812, 0.2891979217529297, -0.04092416912317276, 0.3134591281414032, -0.8315186500549316, 1.293016791343689, -1.0474320650100708, 0.19671043753623962...
func BlindSign(key *rsa.PrivateKey, data []byte) []byte { defer rsaTimeInc(time.Now()) c := new(big.Int).SetBytes(data) m, err := decrypt(rand.Reader, key, c) util.CheckErr(err) b := m.Bytes() return b }
[ -0.348597913980484, 0.05346010625362396, 0.6114565134048462, -0.19243565201759338, -0.8142533302307129, -0.40038707852363586, -0.5661605000495911, 0.1314411759376526, 0.38608306646347046, 0.06009283661842346, -0.494350790977478, 0.5106658339500427, -1.7524809837341309, -0.28363338112831116...
func blind(random io.Reader, key *rsa.PublicKey, c *big.Int) (blinded, unblinder *big.Int, err error) { var r *big.Int for { r, err = rand.Int(random, key.N) if err != nil { return } if r.Cmp(bigZero) == 0 { r = bigOne } ir, ok := modInverse(r, key.N) if ok { bigE := big.NewInt(int64(key.E)) ...
[ -0.5545153021812439, -0.2501254677772522, 0.6758509874343872, -0.45678654313087463, -0.9426732659339905, 0.6430183053016663, 0.2659795582294464, 0.5046408176422119, 0.3451654016971588, 0.577908992767334, -0.1394011229276657, 0.35213786363601685, -1.087589144706726, 0.8414089679718018, 1....
func modInverse(a, n *big.Int) (ia *big.Int, ok bool) { g := new(big.Int) x := new(big.Int) y := new(big.Int) g.GCD(x, y, a, n) if g.Cmp(bigOne) != 0 { return } if x.Cmp(bigOne) < 0 { x.Add(x, n) } return x, true }
[ -1.496582269668579, 1.0141409635543823, 0.5532366633415222, -1.0436222553253174, -0.39792945981025696, -0.046183958649635315, -0.04986627399921417, 0.3372233510017395, -0.3301720917224884, 0.6419628262519836, -0.5575457811355591, -0.003954240120947361, -1.5662875175476074, -0.2661944925785...
func EncryptBig(pub *rsa.PublicKey, m []byte) []byte { defer rsaTimeInc(time.Now()) en := encrypt(new(big.Int), pub, new(big.Int).SetBytes(m)).Bytes() return en }
[ -0.4485446512699127, 0.7714431285858154, 0.39219653606414795, 0.33231258392333984, -0.08577695488929749, 0.13934779167175293, -0.612236499786377, 0.3878291845321655, -0.3191383481025696, 1.3611619472503662, -0.8766319155693054, 0.91060471534729, -0.6646263599395752, 0.7227674126625061, -...
func encrypt(cipher *big.Int, pub *rsa.PublicKey, m *big.Int) *big.Int { e := big.NewInt(int64(pub.E)) cipher.Exp(m, e, pub.N) return cipher }
[ 0.23685194551944733, 1.5309522151947021, 0.21381907165050507, -0.029494810849428177, -0.012063687667250633, -0.3720693588256836, -0.014242580160498619, 0.31879177689552307, 0.5560957193374634, 0.6368539929389954, 0.10590405017137527, 0.4168703258037567, -1.056694746017456, 0.35789561271667...
func (c *Client) EnableAWSOrganizationsAccess(ctx context.Context, params *EnableAWSOrganizationsAccessInput, optFns ...func(*Options)) (*EnableAWSOrganizationsAccessOutput, error) { if params == nil { params = &EnableAWSOrganizationsAccessInput{} } result, metadata, err := c.invokeOperation(ctx, "EnableAWSOrgani...
[ -0.8682654500007629, 0.9277886152267456, 0.793815553188324, -0.5270400047302246, 0.005334485787898302, 0.29442551732063293, 1.6131000518798828, -0.7557461857795715, 0.8941650390625, -0.0035905535332858562, 0.37025994062423706, 0.8862531185150146, 0.9131312966346741, -0.7357615828514099, ...
func GetItems(c *gin.Context) { var items []models.Item if err := models.DB.Order("name").Find(&items).Error; err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Could not find items"}) } c.JSON(http.StatusOK, gin.H{"items": items}) }
[ -0.8238161206245422, 0.0888729840517044, 0.40693628787994385, 0.0873107761144638, 0.5493950247764587, 0.23262757062911987, -0.630352258682251, -0.7587589621543884, -0.7294750809669495, 0.49374449253082275, -0.24518834054470062, 0.2308116853237152, 0.3309303820133209, 0.13412970304489136, ...
func GetItem(c *gin.Context) { var item models.Item if err := models.DB.Where("id = ?", c.Param("id")).First(&item).Error; err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "Record not found!"}) return } c.JSON(http.StatusOK, gin.H{"data": item}) }
[ -0.22231562435626984, 0.4032089114189148, 0.3531685769557953, 0.8440374732017517, 0.7634603977203369, 0.9041721224784851, 0.2092309147119522, -0.01805134117603302, -0.6855885982513428, 0.3145716190338135, 0.5873637795448303, 0.8884269595146179, 0.04283463582396507, -0.22581630945205688, ...
func GetItemNames(c *gin.Context) { type ItemName struct { Name string ID uint } var items []ItemName if err := models.DB.Model(&models.Item{}).Order("name").Find(&items).Error; err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "Couldn't retrieve items"}) return } c.JSON(http.StatusOK, gin.H{"i...
[ -1.152213454246521, 0.29105985164642334, 0.5024738907814026, 0.28812170028686523, 0.716375470161438, -0.27781838178634644, -1.0039067268371582, -0.8798900842666626, -0.3040420413017273, 0.45212194323539734, -1.1466832160949707, 0.5760923624038696, 0.42789125442504883, 0.16728992760181427, ...
func CreateItem(c *gin.Context) { // Validate input var input CreateItemInput if err := c.ShouldBindJSON(&input); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } // Create item item := models.Item{ Name: input.Name, Type: input.Type, Rarity: input.Rarity, Cost: ...
[ -0.7401719689369202, 0.10852012038230896, 0.4031107425689697, 1.3271375894546509, 0.5437021851539612, 1.9002280235290527, -0.05238359421491623, -0.2422366440296173, -1.1251379251480103, 0.6158355474472046, 0.17404408752918243, -0.5286096930503845, -0.27973875403404236, 0.16906607151031494,...
func UpdateItem(c *gin.Context) { // Validate input var input UpdateItemInput if err := c.ShouldBindJSON(&input); err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } // Get model if exist var item models.Item if err := models.DB.Where("id = ?", c.Param("id")).First(&item).Error;...
[ -1.2993721961975098, -0.4797614812850952, 0.5431390404701233, 1.2366020679473877, 0.15890346467494965, 1.5418962240219116, 0.20952428877353668, 0.0996301993727684, -0.8804463148117065, 0.7487055659294128, -0.036549098789691925, 0.026625268161296844, -0.14167220890522003, 0.2068571448326110...
func DeleteItem(c *gin.Context) { // Get model if exist var item models.Item if err := models.DB.Where("id = ?", c.Param("id")).First(&item).Error; err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": "Record not found!"}) return } models.DB.Delete(&item) c.JSON(http.StatusOK, gin.H{"data": true}) }
[ -0.43805253505706787, 0.15843230485916138, 0.5847772359848022, 0.9915192723274231, 0.9855514764785767, 1.4923537969589233, 0.6022762060165405, 0.1563354730606079, -0.5717674493789673, 0.30493098497390747, 0.49712106585502625, 0.2709895074367523, 0.2823775112628937, 0.4581886827945709, -0...
func (cons *RedisSub) Configure(conf core.PluginConfig) error { err := cons.ConsumerBase.Configure(conf) if err != nil { return err } cons.password = conf.GetString("Password", "") cons.address, cons.protocol = shared.ParseAddress(conf.GetString("Address", ":6379")) cons.channel = conf.GetString("Channel", "de...
[ 0.09920985996723175, 0.218620166182518, 0.47291800379753113, 0.434028685092926, 0.6201171875, -1.3082387447357178, -0.40079641342163086, 0.14792202413082123, -0.5677734017372131, 0.002062841085717082, -0.9717184901237488, 0.10639112442731857, -0.6671717166900635, 0.4364835023880005, 0.60...
func NewMockAuthorizer(ctrl *gomock.Controller) *MockAuthorizer { mock := &MockAuthorizer{ctrl: ctrl} mock.recorder = &MockAuthorizerMockRecorder{mock} return mock }
[ -0.33976972103118896, 0.1410403996706009, 0.24148967862129211, 0.902327835559845, -0.6136462688446045, -0.37859052419662476, 0.9330787062644958, -0.08454150706529617, 0.8915907144546509, 0.7156720161437988, -0.38224902749061584, 0.5119059085845947, -0.20500300824642181, 1.301321029663086, ...
func (m *MockAuthorizer) EXPECT() *MockAuthorizerMockRecorder { return m.recorder }
[ 0.10555747896432877, 0.18339163064956665, 0.12644970417022705, 0.3876085579395294, -0.26346713304519653, 0.1577470749616623, 0.2510009706020355, 0.6137364506721497, 0.4680081307888031, -0.1041918620467186, 1.0500433444976807, 0.9163253903388977, -0.523766279220581, 0.7481592297554016, 0....
func (m *MockAuthorizer) Authorize(arg0 protocol.Request, arg1 *tokens.ClientIDClaims) (bool, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Authorize", arg0, arg1) ret0, _ := ret[0].(bool) ret1, _ := ret[1].(error) return ret0, ret1 }
[ -0.9175336360931396, 0.20214861631393433, 0.42511388659477234, 0.4901692569255829, 1.1229017972946167, 0.051582224667072296, 0.7363623976707458, -0.22326724231243134, -0.9618802070617676, 0.5130600929260254, -0.19856517016887665, -0.17592018842697144, -0.7401498556137085, 1.157780051231384...
func (mr *MockAuthorizerMockRecorder) Authorize(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Authorize", reflect.TypeOf((*MockAuthorizer)(nil).Authorize), arg0, arg1) }
[ -0.4079950153827667, 0.9633023142814636, 0.3303770124912262, 0.6744983792304993, 0.39530596137046814, -0.17173539102077484, -0.01770712062716484, -0.6611594557762146, 0.18163929879665375, 1.2005462646484375, 0.9702088236808777, 0.7219158411026001, -1.1088426113128662, 1.6694132089614868, ...
func (d *Dao) ViewerBaseCache(c context.Context, mid int64, dt string) (res map[string]*data.ViewerBase, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() // get cache r, err = conn.Get(keyBase(mid, dt)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { ...
[ -0.7369431257247925, -0.07190347462892532, 0.6264368295669556, -0.20947864651679993, -1.0785987377166748, -1.112640142440796, -0.2998245656490326, -0.5098518133163452, -0.20869563519954681, 0.7336289286613464, -0.08298153430223465, 0.6156083345413208, -0.6705076694488525, 0.146382033824920...
func (d *Dao) AddViewerBaseCache(c context.Context, mid int64, dt string, res map[string]*data.ViewerBase) (err error) { key := keyBase(mid, dt) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { log.Error...
[ -0.574394166469574, -0.084896519780159, 0.7408996224403381, 0.009636932983994484, -0.9207106828689575, -0.33752134442329407, -0.6954066753387451, -0.09120279550552368, -0.1774131804704666, 0.09951937943696976, -0.2269047051668167, -0.1274206042289734, -0.7686570286750793, 0.345833718776702...
func (d *Dao) ViewerAreaCache(c context.Context, mid int64, dt string) (res map[string]map[string]int64, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() // get cache r, err = conn.Get(keyArea(mid, dt)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { ...
[ -0.9289224743843079, -0.08854907751083374, 0.6924938559532166, -0.7834688425064087, -1.384731411933899, -0.9217413067817688, 0.02996615320444107, -0.36515989899635315, 0.45582717657089233, 0.940899133682251, 0.6371228098869324, 0.7929418683052063, 0.2194920927286148, 0.7945529222488403, ...
func (d *Dao) AddViewerAreaCache(c context.Context, mid int64, dt string, res map[string]map[string]int64) (err error) { key := keyArea(mid, dt) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { log.Error...
[ -0.5280322432518005, -0.24274002015590668, 0.8400387167930603, -0.8181408047676086, -1.0456546545028687, -0.24039478600025177, -0.42761990427970886, 0.13245341181755066, 0.6638591885566711, 0.30137479305267334, 0.686240553855896, -0.12240120023488998, -0.2796213924884796, 0.730018913745880...
func (d *Dao) TrendCache(c context.Context, mid int64, dt string) (res map[string]*data.ViewerTrend, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() // get cache r, err = conn.Get(keyTrend(mid, dt)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { lo...
[ -0.3314010202884674, 0.14601652324199677, 0.5039122700691223, -0.3271236717700958, -0.9180583953857422, -1.0094187259674072, 0.016545908525586128, -0.532744824886322, -0.009251066483557224, 0.4640730619430542, -0.3006899356842041, 1.1273890733718872, -0.504426121711731, 0.10599205642938614...
func (d *Dao) AddTrendCache(c context.Context, mid int64, dt string, res map[string]*data.ViewerTrend) (err error) { key := keyTrend(mid, dt) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { log.Error("m...
[ 0.05109841004014015, 0.047545358538627625, 0.629157543182373, -0.3608640134334564, -0.4064893126487732, -0.3958530128002167, -0.13137565553188324, -0.04423932731151581, 0.16803641617298126, -0.2505292296409607, -0.45558109879493713, 0.2324293553829193, -0.4196000397205353, 0.22566196322441...
func (d *Dao) RelationFansDayCache(c context.Context, mid int64, dt string) (res map[string]map[string]int, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() // get cache r, err = conn.Get(keyRfd(mid, dt)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { ...
[ -0.9681686162948608, 0.45262590050697327, 0.8392050862312317, -0.1112079918384552, -0.6387223601341248, -0.8520233631134033, -0.26128870248794556, -0.9066305756568909, -0.012529516592621803, -0.02180364541709423, 0.2022349089384079, -0.34231317043304443, -0.42360684275627136, 0.08117079734...
func (d *Dao) AddRelationFansDayCache(c context.Context, mid int64, dt string, res map[string]map[string]int) (err error) { key := keyRfd(mid, dt) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { log.Err...
[ -0.6563475728034973, 0.5604387521743774, 0.8367449641227722, -0.022217698395252228, -0.2627559006214142, 0.12473119795322418, -0.27065375447273254, -0.20207951962947845, -0.07325111329555511, -0.7433666586875916, 0.07563123852014542, -0.9467586278915405, -0.5031049847602844, -0.03265073895...
func (d *Dao) RelationFansMonthCache(c context.Context, mid int64, dt string) (res map[string]map[string]int, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() r, err = conn.Get(keyRfm(mid, dt)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { log.Error...
[ -0.6346240639686584, 0.17503346502780914, 0.6365929841995239, -0.28973788022994995, -0.6078671216964722, -1.1466065645217896, -0.22966265678405762, -0.8509703874588013, 0.12041480094194412, 0.1159653291106224, -0.04539122432470322, -0.24207304418087006, -0.5650979280471802, 0.1459678411483...
func (d *Dao) AddRelationFansMonthCache(c context.Context, mid int64, dt string, res map[string]map[string]int) (err error) { key := keyRfm(mid, dt) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { log.E...
[ -0.34432169795036316, 0.26413318514823914, 0.7145775556564331, -0.11504212021827698, -0.14019092917442322, -0.18920676410198212, -0.2081453949213028, -0.2503402531147003, 0.15490733087062836, -0.37640953063964844, -0.3891589045524597, -0.8063094615936279, -0.7350596785545349, 0.01979120448...
func (d *Dao) ViewerActionHourCache(c context.Context, mid int64, dt string) (res map[string]*data.ViewerActionHour, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() r, err = conn.Get(keyAct(mid, dt)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { lo...
[ -0.6175069212913513, -0.6299172043800354, 0.44284865260124207, -0.1512686163187027, -1.055133581161499, -0.4067234992980957, 0.010464495979249477, -0.5029106736183167, 0.27051842212677, 1.2898316383361816, 0.09992194920778275, 0.4803433120250702, -0.09646693617105484, -0.08419214934110641,...
func (d *Dao) AddViewerActionHourCache(c context.Context, mid int64, dt string, res map[string]*data.ViewerActionHour) (err error) { key := keyAct(mid, dt) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { ...
[ -0.4177253246307373, -0.6355189681053162, 0.621542751789093, -0.05547146126627922, -0.7801550030708313, 0.1231301799416542, -0.4444153904914856, 0.06758520752191544, 0.21124020218849182, 0.714453935623169, -0.21536989510059357, -0.4347580373287201, -0.29141974449157715, 0.01048212964087724...
func (d *Dao) ViewerIncrCache(c context.Context, mid int64, ty, dt string) (res *data.ViewerIncr, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() // get cache r, err = conn.Get(keyViewIncr(mid, ty, dt)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { ...
[ -0.6548872590065002, 0.45521092414855957, 0.5854269862174988, -0.4486088156700134, -1.5706268548965454, -1.0369951725006104, -0.3087563216686249, -0.46554651856422424, -0.01901240646839142, 0.4620707035064697, 0.6064675450325012, 0.9105044603347778, -0.8832830190658569, -0.0841606333851814...
func (d *Dao) AddViewerIncrCache(c context.Context, mid int64, ty, dt string, res *data.ViewerIncr) (err error) { key := keyViewIncr(mid, ty, dt) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { log.Erro...
[ -0.4731236398220062, 0.2228166162967682, 0.715645432472229, -0.5946220755577087, -1.2157888412475586, -0.19360452890396118, -0.504673957824707, -0.03129541501402855, -0.21654529869556427, -0.19411203265190125, 0.24356746673583984, 0.11903411895036697, -0.8291429281234741, -0.06319095939397...
func (d *Dao) ThirtyDayArchiveCache(c context.Context, mid int64, ty string) (res []*data.ThirtyDay, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() // get cache r, err = conn.Get(keyThirtyDayArchive(mid, ty)) if err != nil { if err == memcache.ErrNotFound { err = nil } e...
[ -1.3226251602172852, 0.08969287574291229, 0.4585661292076111, -0.38911014795303345, 0.07967591285705566, -0.8809848427772522, -0.9237555265426636, -0.6910466551780701, 0.4548271596431732, 1.1333098411560059, -0.38444873690605164, 0.19338852167129517, -0.6435748338699341, 0.0645214617252349...
func (d *Dao) AddThirtyDayArchiveCache(c context.Context, mid int64, ty string, res []*data.ThirtyDay) (err error) { key := keyThirtyDayArchive(mid, ty) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { l...
[ -1.0256494283676147, -0.012789643369615078, 0.7446734309196472, -0.9217509627342224, 0.4952883720397949, -0.5256994962692261, -0.4932321310043335, -0.07102793455123901, 0.4531122148036957, 0.3952554762363434, -0.21068495512008667, -0.5826868414878845, -0.22211070358753204, -0.4822390675544...
func (d *Dao) ThirtyDayArticleCache(c context.Context, mid int64) (res []*artmdl.ThirtyDayArticle, err error) { var ( conn = d.mc.Get(c) r *memcache.Item ) defer conn.Close() // get cache r, err = conn.Get(keyThirtyDayArticle(mid)) if err != nil { if err == memcache.ErrNotFound { err = nil } else { ...
[ -1.156917929649353, -0.1709931194782257, 0.25752660632133484, -0.7806467413902283, -0.1451537162065506, -0.8620970249176025, -0.6820675730705261, -0.7881195545196533, -0.0536859892308712, 1.2634941339492798, -0.357735276222229, -0.20234116911888123, -0.7924784421920776, -0.2282326817512512...
func (d *Dao) AddThirtyDayArticleCache(c context.Context, mid int64, res []*artmdl.ThirtyDayArticle) (err error) { key := keyThirtyDayArticle(mid) conn := d.mc.Get(c) defer conn.Close() if err = conn.Set(&memcache.Item{Key: key, Object: res, Flags: memcache.FlagJSON, Expiration: d.mcExpire}); err != nil { log.Err...
[ -0.9200746417045593, -0.1510360985994339, 0.5977200865745544, -1.1724907159805298, 0.3060532510280609, -0.34903618693351746, -0.4654786288738251, -0.23274217545986176, 0.2312275916337967, 0.8608291745185852, -0.2381560355424881, -0.8484184145927429, -0.832669198513031, -0.726087212562561, ...
func Truish(s string) bool { return s == "1" || strings.ToLower(s) == "true" || strings.ToLower(s) == "on" }
[ 0.32621464133262634, 0.10638313740491867, 0.4495292603969574, -0.3897069990634918, -0.8550183176994324, 0.4977383315563202, -0.4227256774902344, 0.19213512539863586, 0.17084018886089325, 0.5708968043327332, -0.31789010763168335, 1.081432580947876, -0.4435615539550781, 0.18387562036514282, ...
func FormatValue(format string, val interface{}) string { switch val := val.(type) { case bool: if format == "%d" { if val { return "1" } return "0" } } if format == "" { format = "%v" } return fmt.Sprintf(format, val) }
[ -0.08640403300523758, -0.43948104977607727, 0.9066497683525085, 0.7243247628211975, -0.6949842572212219, -0.08638867735862732, -0.4402197599411011, -0.11657062917947769, 0.2017771154642105, 0.10552755743265152, 1.9118870496749878, 0.6458203792572021, 0.7275641560554504, 1.6353814601898193,...
func (s *CacheService) Get(base string) *RatesStore { // Is our cache expired? if s.IsExpired(base) { return nil } // Use stored results. return cache[base] }
[ -0.02060200832784176, 0.42695149779319763, 0.2911490797996521, -0.22136394679546356, -0.17947489023208618, -0.5427863001823425, -1.5056906938552856, -1.144993782043457, -0.030003296211361885, -0.5225937962532043, 0.21547594666481018, 0.07330337911844254, -1.2536126375198364, -0.44597333669...
func (s *CacheService) Store(base string, rates map[string]decimal.Decimal) { // No cache? Initalize it. if cache == nil { cache = map[string]*RatesStore{} } // Store tn := time.Now() cache[base] = &RatesStore{ Rates: rates, UpdatedAt: &tn, Base: base, } }
[ -0.12635938823223114, -0.1104879379272461, 0.40789657831192017, -0.4464196264743805, -0.19372966885566711, 0.47011858224868774, -0.9345021843910217, -0.7005602121353149, -0.37950044870376587, -0.71014404296875, -0.8111199140548706, -0.32679182291030884, -0.7686110734939575, 0.0578219629824...
func (s *CacheService) IsExpired(base string) bool { // No cache? bail. if cache[base] == nil || (len(cache[base].Rates) <= 0) { return true } // Expired cache? bail. lastUpdated := cache[base].UpdatedAt if lastUpdated != nil && lastUpdated.Add(cacheTTL).Before(time.Now()) { return true } return false }
[ -0.30599886178970337, -0.1578749269247055, 0.5227483510971069, 0.17980735003948212, -0.6776469945907593, -0.23933331668376923, -1.9363001585006714, -0.5712637901306152, 0.2694396376609802, 0.4047949016094208, -0.1884513646364212, -0.13102801144123077, -0.6010388731956482, 0.787300765514373...
func (s *CacheService) Expire(base string) { cache[base] = nil }
[ 0.009236731566488743, 0.16046687960624695, 0.06947329640388489, -0.11968240141868591, -0.11678628623485565, -0.4965227544307709, -1.579022765159607, -0.46208757162094116, -0.08635883033275604, 0.1494433432817459, -0.9106871485710144, 0.3223321735858917, -0.45156559348106384, 0.763081729412...
func InitRedisConnPool() { addr := "221.228.106.9:4019" maxIdle := 10000 idleTimeout := 240 * time.Second connTimeout := time.Duration(1000) * time.Millisecond readTimeout := time.Duration(1000) * time.Millisecond writeTimeout := time.Duration(1000) * time.Millisecond RedisConnPool = &redis.Pool{ MaxIdle: ...
[ -0.1164776086807251, -0.3167334496974945, 0.8087932467460632, -0.41846004128456116, 0.24375630915164948, 0.35972774028778076, 0.3489617109298706, -0.028127366676926613, 0.4413718283176422, 0.4671720862388611, -0.44653549790382385, 0.40214893221855164, -0.2872532606124878, 0.265260994434356...
func getQuote(sym string) string { sym = strings.ToUpper(sym) url := fmt.Sprintf("http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=nsl1op&e=.csv", sym) resp, err := http.Get(url) if err != nil { return fmt.Sprintf("error: %v", err) } rows, err := csv.NewReader(resp.Body).ReadAll() if err != nil { return...
[ -0.5134345889091492, -0.10321551561355591, 0.7914965152740479, 0.1910455971956253, 0.46243956685066223, -1.1620144844055176, -0.1700238436460495, -0.5498809218406677, 0.2259160578250885, 0.7266475558280945, 0.3696243464946747, 0.49813854694366455, -0.6101775169372559, 0.6012026071548462, ...