@@ -372,56 +372,27 @@ type GetLayerOptions struct {
372
372
PersistedValues UserPersistedValues
373
373
}
374
374
375
- type gateResponse struct {
376
- Name string `json:"name"`
377
- Value bool `json:"value"`
378
- RuleID string `json:"rule_id"`
379
- }
380
-
381
- type configResponse struct {
382
- Name string `json:"name"`
383
- Value map [string ]interface {} `json:"value"`
384
- RuleID string `json:"rule_id"`
385
- }
386
-
387
- type checkGateInput struct {
388
- GateName string `json:"gateName"`
389
- User User `json:"user"`
390
- StatsigMetadata statsigMetadata `json:"statsigMetadata"`
391
- }
392
-
393
- type getConfigInput struct {
394
- ConfigName string `json:"configName"`
395
- User User `json:"user"`
396
- StatsigMetadata statsigMetadata `json:"statsigMetadata"`
397
- }
398
-
399
375
func (c * Client ) checkGateImpl (user User , name string , context * evalContext ) FeatureGate {
400
376
if ! c .verifyUser (user ) {
401
377
return * NewGate (name , false , "" , "" , nil )
402
378
}
403
379
user = normalizeUser (user , * c .options )
404
380
res := c .evaluator .evalGate (user , name , context )
405
- if res .FetchFromServer {
406
- serverRes := fetchGate (user , name , c .transport )
407
- res = & evalResult {Value : serverRes .Value , RuleID : serverRes .RuleID }
408
- } else {
409
- exposure := c .logger .logGateExposure (user , name , res , context )
381
+ exposure := c .logger .logGateExposure (user , name , res , context )
410
382
411
- if c .options .EvaluationCallbacks .GateEvaluationCallback != nil {
412
- if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
413
- c .options .EvaluationCallbacks .GateEvaluationCallback (name , res .Value , exposure )
414
- } else {
415
- c .options .EvaluationCallbacks .GateEvaluationCallback (name , res .Value , nil )
416
- }
383
+ if c .options .EvaluationCallbacks .GateEvaluationCallback != nil {
384
+ if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
385
+ c .options .EvaluationCallbacks .GateEvaluationCallback (name , res .Value , exposure )
386
+ } else {
387
+ c .options .EvaluationCallbacks .GateEvaluationCallback (name , res .Value , nil )
417
388
}
389
+ }
418
390
419
- if c .options .EvaluationCallbacks .ExposureCallback != nil {
420
- if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
421
- c .options .EvaluationCallbacks .ExposureCallback (name , exposure )
422
- } else {
423
- c .options .EvaluationCallbacks .ExposureCallback (name , nil )
424
- }
391
+ if c .options .EvaluationCallbacks .ExposureCallback != nil {
392
+ if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
393
+ c .options .EvaluationCallbacks .ExposureCallback (name , exposure )
394
+ } else {
395
+ c .options .EvaluationCallbacks .ExposureCallback (name , nil )
425
396
}
426
397
}
427
398
return * NewGate (name , res .Value , res .RuleID , res .GroupName , res .EvaluationDetails )
@@ -434,32 +405,27 @@ func (c *Client) getConfigImpl(user User, name string, context *evalContext) Dyn
434
405
user = normalizeUser (user , * c .options )
435
406
res := c .evaluator .evalConfig (user , name , context )
436
407
config := * NewConfig (name , res .JsonValue , res .RuleID , res .GroupName , res .EvaluationDetails )
437
- if res .FetchFromServer {
438
- res = c .fetchConfigFromServer (user , name )
439
- config = * NewConfig (name , res .JsonValue , res .RuleID , res .GroupName , res .EvaluationDetails )
440
- } else {
441
- exposure := c .logger .logConfigExposure (user , name , res , context )
408
+ exposure := c .logger .logConfigExposure (user , name , res , context )
442
409
443
- if context .IsExperiment && c .options .EvaluationCallbacks .ExperimentEvaluationCallback != nil {
444
- if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
445
- c .options .EvaluationCallbacks .ExperimentEvaluationCallback (name , config , exposure )
446
- } else {
447
- c .options .EvaluationCallbacks .ExperimentEvaluationCallback (name , config , nil )
448
- }
449
- } else if c .options .EvaluationCallbacks .ConfigEvaluationCallback != nil {
450
- if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
451
- c .options .EvaluationCallbacks .ConfigEvaluationCallback (name , config , exposure )
452
- } else {
453
- c .options .EvaluationCallbacks .ConfigEvaluationCallback (name , config , nil )
454
- }
410
+ if context .IsExperiment && c .options .EvaluationCallbacks .ExperimentEvaluationCallback != nil {
411
+ if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
412
+ c .options .EvaluationCallbacks .ExperimentEvaluationCallback (name , config , exposure )
413
+ } else {
414
+ c .options .EvaluationCallbacks .ExperimentEvaluationCallback (name , config , nil )
415
+ }
416
+ } else if c .options .EvaluationCallbacks .ConfigEvaluationCallback != nil {
417
+ if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
418
+ c .options .EvaluationCallbacks .ConfigEvaluationCallback (name , config , exposure )
419
+ } else {
420
+ c .options .EvaluationCallbacks .ConfigEvaluationCallback (name , config , nil )
455
421
}
422
+ }
456
423
457
- if c .options .EvaluationCallbacks .ExposureCallback != nil {
458
- if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
459
- c .options .EvaluationCallbacks .ExposureCallback (name , exposure )
460
- } else {
461
- c .options .EvaluationCallbacks .ExposureCallback (name , nil )
462
- }
424
+ if c .options .EvaluationCallbacks .ExposureCallback != nil {
425
+ if c .options .EvaluationCallbacks .IncludeDisabledExposures || ! context .DisableLogExposures {
426
+ c .options .EvaluationCallbacks .ExposureCallback (name , exposure )
427
+ } else {
428
+ c .options .EvaluationCallbacks .ExposureCallback (name , nil )
463
429
}
464
430
}
465
431
return config
@@ -473,10 +439,6 @@ func (c *Client) getLayerImpl(user User, name string, context *evalContext) Laye
473
439
user = normalizeUser (user , * c .options )
474
440
res := c .evaluator .evalLayer (user , name , context )
475
441
476
- if res .FetchFromServer {
477
- res = c .fetchConfigFromServer (user , name )
478
- }
479
-
480
442
logFunc := func (layer Layer , parameterName string ) {
481
443
exposure := c .logger .logLayerExposure (user , layer , parameterName , res , context )
482
444
if c .options .EvaluationCallbacks .LayerEvaluationCallback != nil {
@@ -498,41 +460,6 @@ func (c *Client) getLayerImpl(user User, name string, context *evalContext) Laye
498
460
return * NewLayer (name , res .JsonValue , res .RuleID , res .GroupName , & logFunc , res .ConfigDelegate )
499
461
}
500
462
501
- func fetchGate (user User , gateName string , t * transport ) gateResponse {
502
- input := & checkGateInput {
503
- GateName : gateName ,
504
- User : user ,
505
- StatsigMetadata : t .metadata ,
506
- }
507
- var res gateResponse
508
- _ , err := t .post ("/check_gate" , input , & res , RequestOptions {}, nil )
509
- if err != nil {
510
- return gateResponse {
511
- Name : gateName ,
512
- Value : false ,
513
- RuleID : "" ,
514
- }
515
- }
516
- return res
517
- }
518
-
519
- func fetchConfig (user User , configName string , t * transport ) configResponse {
520
- input := & getConfigInput {
521
- ConfigName : configName ,
522
- User : user ,
523
- StatsigMetadata : t .metadata ,
524
- }
525
- var res configResponse
526
- _ , err := t .post ("/get_config" , input , & res , RequestOptions {}, nil )
527
- if err != nil {
528
- return configResponse {
529
- Name : configName ,
530
- RuleID : "" ,
531
- }
532
- }
533
- return res
534
- }
535
-
536
463
func normalizeUser (user User , options Options ) User {
537
464
env := make (map [string ]string )
538
465
// Copy to avoid data race. We modify the map below.
@@ -548,11 +475,3 @@ func normalizeUser(user User, options Options) User {
548
475
user .StatsigEnvironment = env
549
476
return user
550
477
}
551
-
552
- func (c * Client ) fetchConfigFromServer (user User , configName string ) * evalResult {
553
- serverRes := fetchConfig (user , configName , c .transport )
554
- return & evalResult {
555
- JsonValue : serverRes .Value ,
556
- RuleID : serverRes .RuleID ,
557
- }
558
- }
0 commit comments