segment

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package segment //

Package segment //

Package segment //

Package segment //

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCacheKey

func MakeCacheKey(userID string) string

MakeCacheKey creates and returns cacheKey

Types

type APIManager

type APIManager interface {
	// not passing ODPConfig here to avoid multiple mutex lock calls inside async requests
	FetchQualifiedSegments(apiKey, apiHost, userID string, segmentsToCheck []string) ([]string, error)
}

APIManager represents the segment API manager.

type Audience

type Audience struct {
	Name        string `json:"name"`
	State       string `json:"state"`
	Description string `json:"description,omitempty"`
}

Audience represents an ODP Audience

type DefaultSegmentAPIManager

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

DefaultSegmentAPIManager represents default implementation of Segment API Manager

func NewSegmentAPIManager

func NewSegmentAPIManager(sdkKey string, requester pkgUtils.Requester) *DefaultSegmentAPIManager

NewSegmentAPIManager creates and returns a new instance of DefaultSegmentAPIManager.

func (*DefaultSegmentAPIManager) FetchQualifiedSegments

func (sm *DefaultSegmentAPIManager) FetchQualifiedSegments(apiKey, apiHost, userID string, segmentsToCheck []string) ([]string, error)

FetchQualifiedSegments returns qualified ODP segments

type DefaultSegmentManager

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

DefaultSegmentManager represents default implementation of odp segment manager

func NewSegmentManager

func NewSegmentManager(sdkKey string, options ...SMOptionFunc) *DefaultSegmentManager

NewSegmentManager creates and returns a new instance of DefaultSegmentManager.

func (*DefaultSegmentManager) FetchQualifiedSegments

func (s *DefaultSegmentManager) FetchQualifiedSegments(apiKey, apiHost, userID string, segmentsToCheck []string, options []OptimizelySegmentOption) (segments []string, err error)

FetchQualifiedSegments fetches and returns qualified segments

func (*DefaultSegmentManager) Reset

func (s *DefaultSegmentManager) Reset()

Reset resets segmentsCache.

type Manager

type Manager interface {
	FetchQualifiedSegments(apiKey, apiHost, userID string, segmentsToCheck []string, options []OptimizelySegmentOption) (segments []string, err error)
	Reset()
}

Manager represents the odp segment manager.

type OptimizelySegmentOption

type OptimizelySegmentOption string

OptimizelySegmentOption represents options controlling audience segments.

const (
	// IgnoreCache ignores cache (save/lookup)
	IgnoreCache OptimizelySegmentOption = "IGNORE_CACHE"
	// ResetCache resets cache
	ResetCache OptimizelySegmentOption = "RESET_CACHE"
)

func TranslateOptions

func TranslateOptions(options []string) ([]OptimizelySegmentOption, error)

TranslateOptions converts string options array to array of OptimizelySegmentOptions

type SMOptionFunc

type SMOptionFunc func(em *DefaultSegmentManager)

SMOptionFunc are the SegmentManager options that give you the ability to add one more more options before the segment manager is initialized.

func WithAPIManager

func WithAPIManager(segmentAPIManager APIManager) SMOptionFunc

WithAPIManager sets segmentAPIManager as a config option to be passed into the NewSegmentManager method

func WithSegmentsCache

func WithSegmentsCache(segmentsCache cache.Cache) SMOptionFunc

WithSegmentsCache sets cache option to be passed into the NewSegmentManager method

func WithSegmentsCacheSize

func WithSegmentsCacheSize(segmentsCacheSize int) SMOptionFunc

WithSegmentsCacheSize sets segmentsCacheSize option to be passed into the NewSegmentManager method. default value is 10000

func WithSegmentsCacheTimeout

func WithSegmentsCacheTimeout(segmentsCacheTimeout time.Duration) SMOptionFunc

WithSegmentsCacheTimeout sets segmentsCacheTimeout option to be passed into the NewSegmentManager method default value is 600s

Jump to

Keyboard shortcuts

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