client

package
v6.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2025 License: Apache-2.0 Imports: 41 Imported by: 16

Documentation

Overview

Package client contains implementations of the Split SDK client and the factory used to instantiate it.

Index

Constants

View Source
const MaxEventLength = 32768

MaxEventLength constant to limit the event size

View Source
const MaxLength = 250

MaxLength constant to check the length of the feature flags

View Source
const RegExpEventType = "^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$"

RegExpEventType constant that EventType must match

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	MatchingKey  string
	BucketingKey string
}

Key struct to be used when supplying two keys. One for matching purposes and another one for hashing.

func NewKey

func NewKey(matchingKey string, bucketingKey string) *Key

NewKey instantiates a new key

type SplitClient

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

SplitClient is the entry-point of the split SDK.

func (*SplitClient) BlockUntilReady

func (c *SplitClient) BlockUntilReady(timer int) error

BlockUntilReady Calls BlockUntilReady on factory to block client on readiness

func (*SplitClient) Destroy

func (c *SplitClient) Destroy()

Destroy the client and the underlying factory.

func (*SplitClient) Track

func (c *SplitClient) Track(key string, trafficType string, eventType string, value interface{}, properties map[string]interface{}) (ret error)

Track an event and its custom value

func (*SplitClient) Treatment

func (c *SplitClient) Treatment(key interface{}, featureFlagName string, attributes map[string]interface{}) string

Treatment implements the main functionality of split. Retrieve treatments of a specific feature flag for a certain key and set of attributes

func (*SplitClient) TreatmentWithConfig

func (c *SplitClient) TreatmentWithConfig(key interface{}, featureFlagName string, attributes map[string]interface{}) TreatmentResult

TreatmentWithConfig implements the main functionality of split. Retrieves the treatment of a specific feature flag with the corresponding configuration if it is present

func (*SplitClient) Treatments

func (c *SplitClient) Treatments(key interface{}, featureFlagNames []string, attributes map[string]interface{}) map[string]string

Treatments evaluates multiple feature flag names for a single user and set of attributes at once

func (*SplitClient) TreatmentsByFlagSet added in v6.5.0

func (c *SplitClient) TreatmentsByFlagSet(key interface{}, flagSet string, attributes map[string]interface{}) map[string]string

Treatments evaluate multiple feature flag names belonging to a flag set for a single user and a set of attributes at once

func (*SplitClient) TreatmentsByFlagSets added in v6.5.0

func (c *SplitClient) TreatmentsByFlagSets(key interface{}, flagSets []string, attributes map[string]interface{}) map[string]string

Treatments evaluate multiple feature flag names belonging to flag sets for a single user and a set of attributes at once

func (*SplitClient) TreatmentsWithConfig

func (c *SplitClient) TreatmentsWithConfig(key interface{}, featureFlagNames []string, attributes map[string]interface{}) map[string]TreatmentResult

TreatmentsWithConfig evaluates multiple feature flag names for a single user and set of attributes at once and returns configurations

func (*SplitClient) TreatmentsWithConfigByFlagSet added in v6.5.0

func (c *SplitClient) TreatmentsWithConfigByFlagSet(key interface{}, flagSet string, attributes map[string]interface{}) map[string]TreatmentResult

TreatmentsWithConfigByFlagSet evaluates multiple feature flag names belonging to a flag set for a single user and set of attributes at once and returns configurations

func (*SplitClient) TreatmentsWithConfigByFlagSets added in v6.5.0

func (c *SplitClient) TreatmentsWithConfigByFlagSets(key interface{}, flagSets []string, attributes map[string]interface{}) map[string]TreatmentResult

TreatmentsWithConfigByFlagSet evaluates multiple feature flag names belonging to a flag sets for a single user and set of attributes at once and returns configurations

type SplitFactory

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

SplitFactory struct is responsible for instantiating and storing instances of client and manager.

func NewSplitFactory

func NewSplitFactory(apikey string, cfg *conf.SplitSdkConfig) (*SplitFactory, error)

NewSplitFactory instantiates a new SplitFactory object. Accepts a SplitSdkConfig struct as an argument, which will be used to instantiate both the client and the manager

func (*SplitFactory) BlockUntilReady

func (f *SplitFactory) BlockUntilReady(timer int) error

BlockUntilReady blocks client or manager until the SDK is ready, error occurs or times out

func (*SplitFactory) Client

func (f *SplitFactory) Client() *SplitClient

Client returns the split client instantiated by the factory

func (*SplitFactory) Destroy

func (f *SplitFactory) Destroy()

Destroy stops all async tasks and clears all storages

func (*SplitFactory) IsDestroyed

func (f *SplitFactory) IsDestroyed() bool

IsDestroyed returns true if the client has been destroyed

func (*SplitFactory) IsReady

func (f *SplitFactory) IsReady() bool

IsReady returns true if the factory is ready

func (*SplitFactory) Manager

func (f *SplitFactory) Manager() *SplitManager

Manager returns the split manager instantiated by the factory

type SplitManager

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

SplitManager provides information of the currently stored splits

func (*SplitManager) BlockUntilReady

func (m *SplitManager) BlockUntilReady(timer int) error

BlockUntilReady Calls BlockUntilReady on factory to block manager on readiness

func (*SplitManager) Split

func (m *SplitManager) Split(featureFlagName string) *SplitView

Split returns a partial view of a particular feature flag

func (*SplitManager) SplitNames

func (m *SplitManager) SplitNames() []string

SplitNames returns a list with the name of all the currently stored feature flags

func (*SplitManager) Splits

func (m *SplitManager) Splits() []SplitView

Splits returns a list of a partial view of every currently stored feature flag

type SplitView

type SplitView struct {
	Name                string              `json:"name"`
	TrafficType         string              `json:"trafficType"`
	Killed              bool                `json:"killed"`
	Treatments          []string            `json:"treatments"`
	ChangeNumber        int64               `json:"changeNumber"`
	Configs             map[string]string   `json:"configs"`
	DefaultTreatment    string              `json:"defaultTreatment"`
	Sets                []string            `json:"sets"`
	ImpressionsDisabled bool                `json:"impressionsDisabled"`
	Prerequisites       []dtos.Prerequisite `json:"prerequisites"`
}

SplitView is a partial representation of a currently stored split

type TreatmentResult

type TreatmentResult struct {
	Treatment string  `json:"treatment"`
	Config    *string `json:"config"`
}

TreatmentResult struct that includes the Treatment evaluation with the corresponding Config

Jump to

Keyboard shortcuts

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