featureprobe

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

README

FeatureProbe Server Side SDK for Golang

Top Language codecov Github Star Apache-2.0 license

Feature Probe is an open source feature management service. This SDK is used to control features in java programs. This SDK is designed primarily for use in multi-user systems such as web servers and applications.

Basic Terms

Reading the short Introduction will help to understand the code blow more easily. 中文

How to Use This SDK

See SDK Doc for detail. 中文

Contributing

We are working on continue evolving FeatureProbe core, making it flexible and easier to use. Development of FeatureProbe happens in the open on GitHub, and we are grateful to the community for contributing bugfixes and improvements.

Please read CONTRIBUTING for details on our code of conduct, and the process for taking part in improving FeatureProbe.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var USER_AGENT string = "Go/" + VERSION
View Source
var VERSION string = "1.1.0"

Functions

This section is empty.

Types

type Access

type Access struct {
	StartTime int64                      `json:"startTime"`
	EndTime   int64                      `json:"endTime"`
	Counters  map[string][]ToggleCounter `json:"counters"`
}

type AccessEvent

type AccessEvent struct {
	Time    int64       `json:"time"`
	Key     string      `json:"key"`
	Value   interface{} `json:"value"`
	Index   *int        `json:"index"`
	Version *uint64     `json:"version"`
	Reason  string      `json:"reason"`
}

type Condition

type Condition struct {
	Type      string   `json:"type"`
	Subject   string   `json:"subject"`
	Predicate string   `json:"predicate"`
	Objects   []string `json:"objects"`
}

type CountValue

type CountValue struct {
	Count int         `json:"count"`
	Value interface{} `json:"value"`
}

type EvalDetail

type EvalDetail struct {
	Value          interface{}
	RuleIndex      *int
	VariationIndex *int
	Version        *uint64
	Reason         string
}

type EventRecorder

type EventRecorder struct {
	// contains filtered or unexported fields
}

func NewEventRecorder

func NewEventRecorder(eventsUrl string, flushInterval time.Duration, auth string) EventRecorder

func (*EventRecorder) RecordAccess

func (e *EventRecorder) RecordAccess(event AccessEvent)

func (*EventRecorder) Start

func (e *EventRecorder) Start()

func (*EventRecorder) Stop added in v1.2.1

func (e *EventRecorder) Stop()

type FPBoolDetail

type FPBoolDetail struct {
	Value     bool
	RuleIndex *int
	Version   *uint64
	Reason    string
}

type FPConfig

type FPConfig struct {
	RemoteUrl       string
	TogglesUrl      string
	EventsUrl       string
	ServerSdkKey    string
	RefreshInterval time.Duration
	StartWait       time.Duration
	Repo            *Repository
}

type FPJsonDetail

type FPJsonDetail struct {
	Value     interface{}
	RuleIndex *int
	Version   *uint64
	Reason    string
}

type FPNumberDetail

type FPNumberDetail struct {
	Value     float64
	RuleIndex *int
	Version   *uint64
	Reason    string
}

type FPStrDetail

type FPStrDetail struct {
	Value     string
	RuleIndex *int
	Version   *uint64
	Reason    string
}

type FPUser

type FPUser struct {
	// contains filtered or unexported fields
}

func NewUser

func NewUser() FPUser

func (FPUser) Get

func (u FPUser) Get(key string) string

func (FPUser) GetAll

func (u FPUser) GetAll() map[string]string

func (FPUser) Key

func (u FPUser) Key() string

func (FPUser) StableRollout added in v1.2.1

func (u FPUser) StableRollout(key string) FPUser

func (FPUser) With

func (u FPUser) With(key string, value string) FPUser

type FeatureProbe

type FeatureProbe struct {
	Config   FPConfig
	Repo     *Repository
	Syncer   *Synchronizer
	Recorder *EventRecorder
}

func NewFeatureProbe

func NewFeatureProbe(config FPConfig) FeatureProbe

func NewFeatureProbeForTest added in v1.2.0

func NewFeatureProbeForTest(toggles map[string]interface{}) FeatureProbe

func (*FeatureProbe) BoolDetail

func (fp *FeatureProbe) BoolDetail(toggle string, user FPUser, defaultValue bool) FPBoolDetail

func (*FeatureProbe) BoolValue

func (fp *FeatureProbe) BoolValue(toggle string, user FPUser, defaultValue bool) bool

func (*FeatureProbe) Close added in v1.2.1

func (fp *FeatureProbe) Close()

func (*FeatureProbe) Initialized added in v1.2.1

func (client *FeatureProbe) Initialized() bool

func (*FeatureProbe) JsonDetail

func (fp *FeatureProbe) JsonDetail(toggle string, user FPUser, defaultValue interface{}) FPJsonDetail

func (*FeatureProbe) JsonValue

func (fp *FeatureProbe) JsonValue(toggle string, user FPUser, defaultValue interface{}) interface{}

func (*FeatureProbe) NumberDetail

func (fp *FeatureProbe) NumberDetail(toggle string, user FPUser, defaultValue float64) FPNumberDetail

func (*FeatureProbe) NumberValue

func (fp *FeatureProbe) NumberValue(toggle string, user FPUser, defaultValue float64) float64

func (*FeatureProbe) StrDetail

func (fp *FeatureProbe) StrDetail(toggle string, user FPUser, defaultValue string) FPStrDetail

func (*FeatureProbe) StrValue

func (fp *FeatureProbe) StrValue(toggle string, user FPUser, defaultValue string) string

type PackedData

type PackedData struct {
	Events []AccessEvent `json:"events"`
	Access Access        `json:"access"`
}

type Range

type Range struct {
	Lower int `json:"-"`
	Upper int `json:"-"`
}

func (*Range) UnmarshalJSON

func (r *Range) UnmarshalJSON(data []byte) error

type Repository

type Repository struct {
	Toggles  map[string]Toggle  `json:"toggles"`
	Segments map[string]Segment `json:"segments"`
}

func (*Repository) Clear added in v1.2.1

func (repo *Repository) Clear()

type Rule

type Rule struct {
	Serve      Serve       `json:"serve"`
	Conditions []Condition `json:"conditions"`
}

type Segment

type Segment struct {
	Key     string `json:"key"`
	UniqId  string `json:"uniqueId"`
	Version uint64 `json:"version"`
	Rules   []Rule `json:"rules"`
}

type Serve

type Serve struct {
	Select *int   `json:"select,omitempty"`
	Split  *Split `json:"split,omitempty"`
}

type Split

type Split struct {
	Distribution [][]Range `json:"distribution"`
	BucketBy     string    `json:"bucketBy,omitempty"`
	Salt         string    `json:"salt,omitempty"`
}

type Synchronizer

type Synchronizer struct {
	RefreshInterval time.Duration
	// contains filtered or unexported fields
}

func NewCustomRepoSynchronizer added in v1.2.1

func NewCustomRepoSynchronizer(repo *Repository) Synchronizer

func NewSynchronizer

func NewSynchronizer(url string, RefreshInterval time.Duration, auth string, repo *Repository) Synchronizer

func (*Synchronizer) Initialized added in v1.2.1

func (s *Synchronizer) Initialized() bool

func (*Synchronizer) Start

func (s *Synchronizer) Start(ready chan<- struct{})

func (*Synchronizer) Stop added in v1.1.0

func (s *Synchronizer) Stop()

type Toggle

type Toggle struct {
	Key           string        `json:"key"`
	Enabled       bool          `json:"enabled"`
	Version       uint64        `json:"version"`
	ForClient     bool          `json:"forClient"`
	DisabledServe Serve         `json:"disabledServe"`
	DefaultServe  Serve         `json:"defaultServe"`
	Rules         []Rule        `json:"rules"`
	Variations    []interface{} `json:"variations"`
}

func (*Toggle) Eval

func (t *Toggle) Eval(user FPUser, segments map[string]Segment) (interface{}, error)

type ToggleCounter

type ToggleCounter struct {
	Value   interface{} `json:"value"`
	Version *uint64     `json:"version"`
	Index   *int        `json:"index"`
	Count   int         `json:"count"`
}

type Toggles

type Toggles struct {
	Toggles  map[string]Toggle  `json:"toggles"`
	Segments map[string]Segment `json:"segments,omitempty"`
}

type Variation

type Variation struct {
	Key     string  `json:"key"`
	Index   *int    `json:"index"`
	Version *uint64 `json:"version"`
}

Jump to

Keyboard shortcuts

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