Skip to content

simpleflags/golang-server-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)