@@ -28,6 +28,12 @@ type IClient interface {
28
28
FloatValueDetails (ctx context.Context , flag string , defaultValue float64 , evalCtx EvaluationContext , options ... Option ) (FloatEvaluationDetails , error )
29
29
IntValueDetails (ctx context.Context , flag string , defaultValue int64 , evalCtx EvaluationContext , options ... Option ) (IntEvaluationDetails , error )
30
30
ObjectValueDetails (ctx context.Context , flag string , defaultValue interface {}, evalCtx EvaluationContext , options ... Option ) (InterfaceEvaluationDetails , error )
31
+
32
+ Boolean (ctx context.Context , flag string , defaultValue bool , evalCtx EvaluationContext , options ... Option ) bool
33
+ String (ctx context.Context , flag string , defaultValue string , evalCtx EvaluationContext , options ... Option ) string
34
+ Float (ctx context.Context , flag string , defaultValue float64 , evalCtx EvaluationContext , options ... Option ) float64
35
+ Int (ctx context.Context , flag string , defaultValue int64 , evalCtx EvaluationContext , options ... Option ) int64
36
+ Object (ctx context.Context , flag string , defaultValue interface {}, evalCtx EvaluationContext , options ... Option ) interface {}
31
37
}
32
38
33
39
// ClientMetadata provides a client's metadata
@@ -57,6 +63,9 @@ type Client struct {
57
63
logger func () logr.Logger
58
64
}
59
65
66
+ // interface guard to ensure that Client implements IClient
67
+ var _ IClient = (* Client )(nil )
68
+
60
69
// NewClient returns a new Client. Name is a unique identifier for this client
61
70
func NewClient (name string ) * Client {
62
71
return & Client {
@@ -580,6 +589,86 @@ func (c *Client) ObjectValueDetails(ctx context.Context, flag string, defaultVal
580
589
return c .evaluate (ctx , flag , Object , defaultValue , evalCtx , * evalOptions )
581
590
}
582
591
592
+ // Boolean performs a flag evaluation that returns a boolean. Any error
593
+ // encountered during the evaluation will result in the default value being
594
+ // returned. To explicitly handle errors, use [BooleanValue] or [BooleanValueDetails]
595
+ //
596
+ // Parameters:
597
+ // - ctx is the standard go context struct used to manage requests (e.g. timeouts)
598
+ // - flag is the key that uniquely identifies a particular flag
599
+ // - defaultValue is returned if an error occurs
600
+ // - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx)
601
+ // - options are optional additional evaluation options e.g. WithHooks & WithHookHints
602
+ func (c * Client ) Boolean (ctx context.Context , flag string , defaultValue bool , evalCtx EvaluationContext , options ... Option ) bool {
603
+ value , _ := c .BooleanValue (ctx , flag , defaultValue , evalCtx , options ... )
604
+
605
+ return value
606
+ }
607
+
608
+ // String performs a flag evaluation that returns a string. Any error
609
+ // encountered during the evaluation will result in the default value being
610
+ // returned. To explicitly handle errors, use [StringValue] or [StringValueDetails]
611
+ //
612
+ // Parameters:
613
+ // - ctx is the standard go context struct used to manage requests (e.g. timeouts)
614
+ // - flag is the key that uniquely identifies a particular flag
615
+ // - defaultValue is returned if an error occurs
616
+ // - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx)
617
+ // - options are optional additional evaluation options e.g. WithHooks & WithHookHints
618
+ func (c * Client ) String (ctx context.Context , flag string , defaultValue string , evalCtx EvaluationContext , options ... Option ) string {
619
+ value , _ := c .StringValue (ctx , flag , defaultValue , evalCtx , options ... )
620
+
621
+ return value
622
+ }
623
+
624
+ // Float performs a flag evaluation that returns a float64. Any error
625
+ // encountered during the evaluation will result in the default value being
626
+ // returned. To explicitly handle errors, use [FloatValue] or [FloatValueDetails]
627
+ //
628
+ // Parameters:
629
+ // - ctx is the standard go context struct used to manage requests (e.g. timeouts)
630
+ // - flag is the key that uniquely identifies a particular flag
631
+ // - defaultValue is returned if an error occurs
632
+ // - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx)
633
+ // - options are optional additional evaluation options e.g. WithHooks & WithHookHints
634
+ func (c * Client ) Float (ctx context.Context , flag string , defaultValue float64 , evalCtx EvaluationContext , options ... Option ) float64 {
635
+ value , _ := c .FloatValue (ctx , flag , defaultValue , evalCtx , options ... )
636
+
637
+ return value
638
+ }
639
+
640
+ // Int performs a flag evaluation that returns an int64. Any error
641
+ // encountered during the evaluation will result in the default value being
642
+ // returned. To explicitly handle errors, use [IntValue] or [IntValueDetails]
643
+ //
644
+ // Parameters:
645
+ // - ctx is the standard go context struct used to manage requests (e.g. timeouts)
646
+ // - flag is the key that uniquely identifies a particular flag
647
+ // - defaultValue is returned if an error occurs
648
+ // - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx)
649
+ // - options are optional additional evaluation options e.g. WithHooks & WithHookHints
650
+ func (c * Client ) Int (ctx context.Context , flag string , defaultValue int64 , evalCtx EvaluationContext , options ... Option ) int64 {
651
+ value , _ := c .IntValue (ctx , flag , defaultValue , evalCtx , options ... )
652
+
653
+ return value
654
+ }
655
+
656
+ // Object performs a flag evaluation that returns an object. Any error
657
+ // encountered during the evaluation will result in the default value being
658
+ // returned. To explicitly handle errors, use [ObjectValue] or [ObjectValueDetails]
659
+ //
660
+ // Parameters:
661
+ // - ctx is the standard go context struct used to manage requests (e.g. timeouts)
662
+ // - flag is the key that uniquely identifies a particular flag
663
+ // - defaultValue is returned if an error occurs
664
+ // - evalCtx is the evaluation context used in a flag evaluation (not to be confused with ctx)
665
+ // - options are optional additional evaluation options e.g. WithHooks & WithHookHints
666
+ func (c * Client ) Object (ctx context.Context , flag string , defaultValue interface {}, evalCtx EvaluationContext , options ... Option ) interface {} {
667
+ value , _ := c .ObjectValue (ctx , flag , defaultValue , evalCtx , options ... )
668
+
669
+ return value
670
+ }
671
+
583
672
func (c * Client ) evaluate (
584
673
ctx context.Context , flag string , flagType Type , defaultValue interface {}, evalCtx EvaluationContext , options EvaluationOptions ,
585
674
) (InterfaceEvaluationDetails , error ) {
0 commit comments