@@ -21,6 +21,9 @@ type Client interface {
2121 Variation (key , defaultVal , userID string , attrs ... Attr ) string
2222 VariationUser (key string , defaultVal string , user lduser.User ) string
2323
24+ Int (key string , defaultVal int , userID string , attrs ... Attr ) int
25+ IntUser (key string , defaultVal int , user lduser.User ) int
26+
2427 AllEnabledFlags (key string ) []string
2528 AllEnabledFlagsUser (key string , user lduser.User ) []string
2629}
@@ -91,6 +94,19 @@ func (c *ldClient) VariationUser(key string, defaultVal string, user lduser.User
9194 return res
9295}
9396
97+ func (c * ldClient ) Int (key string , defaultValue int , userID string , attrs ... Attr ) int {
98+ return c .IntUser (key , defaultValue , c .userWithAttrs (userID , attrs ))
99+ }
100+
101+ func (c * ldClient ) IntUser (key string , defaultVal int , user lduser.User ) int {
102+ res , err := c .IntVariation (key , user , defaultVal )
103+ if err != nil {
104+ c .log .WithError (err ).WithField ("key" , key ).Error ("Failed to load feature flag" )
105+ }
106+ // DefaultValue will be returned if IntVariation returns an error
107+ return res
108+ }
109+
94110func (c * ldClient ) AllEnabledFlags (key string ) []string {
95111 return c .AllEnabledFlagsUser (key , lduser .NewUser (key ))
96112}
0 commit comments