sfsdk

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

README

Simple Flags Server-side SDK for Go


this is experimental repo!!!

Supported GO versions

This version of SDK has been tested with Go 1.14

Install

go get github.com/simpleflags/golang-server-sdk

Usage

First we need to import lib

import sdk "github.com/simpleflags/golang-server-sdk"

Next we initialize client instance for interaction with api

err := sdk.Initialize(sdkKey)

Target definition can be user, device, app etc.

target := map[string]interface{}{
    "identifier": "enver",
}

Evaluating Feature Flag

showFeature, err := sdk.Evaluate(featureFlagKey, &target).Bool(false)

Flush any changes and close the SDK

sdk.close()

Interface

very simple and small interfaces:

type Client interface {
    WaitForInitialization()
    Evaluate(feature string, target evaluation.Target) evaluation.Evaluation
    Close() error
}

type Logger interface {
    Debug(args ...interface{})
    Debugf(template string, args ...interface{})
    Info(args ...interface{})
    Infof(template string, args ...interface{})
    Error(args ...interface{})
    Errorf(template string, args ...interface{})
}

Logger

It is very simple to set logger from your current app configuration:

sdk.SetLogger(your_logger)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

func Evaluate

func Evaluate(feature string, target evaluation.Target) evaluation.Evaluation

func InitWithConnector

func InitWithConnector(connector connector.Connector, options ...client.ConfigOption) error

func Initialize

func Initialize(apiKey string, options ...client.ConfigOption) error

func SetLogger

func SetLogger(logger log.Logger)

SetLogger sets the default logger to be used by this package

func WaitForInitialization

func WaitForInitialization()

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL