Documentation
¶
Index ¶
- Variables
- func GetEnv(name string) string
- func GetOpenFeatureClient(ctx context.Context, args *GetOpenFeatureClientArgs) *openfeature.Client
- func MustParseConfig[T any](ctx context.Context, unparsedConfig []byte, validator *validator.Validate) *T
- func MustParseConfigFile[T any](ctx context.Context, configFilePath string, validator *validator.Validate) *T
- func NewValidator(ctx context.Context) *validator.Validate
- func RegisterCustomFieldValidators(validator *validator.Validate, customFieldValidators CustomFieldValidators)
- func WrapError(err error) error
- func WrapErrorWithPrefix(contextualErrorMessage string, err error) error
- type APIError
- type CustomFieldValidators
- type GetFlagOrEnvFn
- type GetOpenFeatureClientArgs
Constants ¶
This section is empty.
Variables ¶
var ErrInternalServer = errors.New("internal server error")
Functions ¶
func GetEnv ¶
Returns the value of the given environment variable.
Panics if the environment variable isn't set.
func GetOpenFeatureClient ¶
func GetOpenFeatureClient(ctx context.Context, args *GetOpenFeatureClientArgs) *openfeature.Client
Connects to Flagsmith and returns the corresponding Open Feature client.
func MustParseConfig ¶
func MustParseConfig[T any](ctx context.Context, unparsedConfig []byte, validator *validator.Validate) *T
Parses and validates the given unmarshalled config. The parsed config is then returned.
Panics if any error occurs.
func MustParseConfigFile ¶
func MustParseConfigFile[T any](ctx context.Context, configFilePath string, validator *validator.Validate) *T
Parses and validates the config file at the given path. The parsed config is then returned.
Panics if any error occurs.
func RegisterCustomFieldValidators ¶
func RegisterCustomFieldValidators( validator *validator.Validate, customFieldValidators CustomFieldValidators, )
func WrapError ¶
Returns a new error which contains the stacktrace along with the original error message.
func WrapErrorWithPrefix ¶
Returns a new error which contains :
(1) the stacktrace (2) some contextual error message along with the original error message.
Types ¶
type APIError ¶
type APIError error
When the presentation layer (in this case, gRPC server) gets :
(1) an error of type APIError, it straight away sends that to the client.
The gRPC error status code can be decided based on the concrete error type (like
ErrUserNotFound).
(2) any other type of (unexpected) error, it logs that error and sends the ErrInternalServer back
to the client.
The gRPC error status code will always be codes.Internal.
func NewAPIError ¶
Returns an APIError, constructed using the given error message.
type CustomFieldValidators ¶
type GetFlagOrEnvFn ¶
func CreateGetFlagOrEnvValueFn ¶
func CreateGetFlagOrEnvValueFn(envPrefix string) GetFlagOrEnvFn
Usage : flagSet.VisitAll(getFlagOrEnvValue("USERS_MICROSERVICE_"))