Documentation
¶
Overview ¶
Package model provides dev projects and flag override data models for the api handler to use. It exists so that it can also notify observers to support streaming updates
Index ¶
- func ContextWithEventStore(ctx context.Context, store EventStore) context.Context
- func ContextWithStore(ctx context.Context, store Store) context.Context
- func CreateOrSyncProject(ctx context.Context, settings InitialProjectSettings) error
- func DeleteOverride(ctx context.Context, projectKey, flagKey string) error
- func DeleteOverrides(ctx context.Context, projectKey string) error
- func EventStoreMiddleware(store EventStore) mux.MiddlewareFunc
- func ObserversMiddleware(observers *Observers) func(handler http.Handler) http.Handler
- func RestoreDb(ctx context.Context, stream io.Reader) error
- func SetObserversOnContext(ctx context.Context, observers *Observers) context.Context
- func StoreMiddleware(store Store) mux.MiddlewareFunc
- type DebugSession
- type DebugSessionsPage
- type Environment
- type ErrAlreadyExists
- type ErrNotFound
- type Event
- type EventStore
- type EventsPage
- type FlagState
- type FlagValue
- type FlagVariation
- type FlagsState
- type InitialProjectSettings
- type Observer
- type Observers
- type Override
- type OverrideEvent
- type Overrides
- type Project
- type Store
- type SyncEvent
- type Variation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithEventStore ¶ added in v1.18.0
func ContextWithEventStore(ctx context.Context, store EventStore) context.Context
func CreateOrSyncProject ¶ added in v1.9.0
func CreateOrSyncProject(ctx context.Context, settings InitialProjectSettings) error
func DeleteOverride ¶ added in v1.8.1
func DeleteOverrides ¶ added in v1.14.0
func EventStoreMiddleware ¶ added in v1.18.0
func EventStoreMiddleware(store EventStore) mux.MiddlewareFunc
func ObserversMiddleware ¶
func SetObserversOnContext ¶
func StoreMiddleware ¶
func StoreMiddleware(store Store) mux.MiddlewareFunc
Types ¶
type DebugSession ¶ added in v1.18.0
type DebugSession struct {
Key string `json:"key"`
WrittenAt time.Time `json:"written_at"`
EventCount int64 `json:"event_count"`
}
DebugSession represents a debug session with metadata
type DebugSessionsPage ¶ added in v1.18.0
type DebugSessionsPage struct {
Sessions []DebugSession `json:"sessions"`
TotalCount int64 `json:"total_count"`
HasMore bool `json:"has_more"`
}
DebugSessionsPage represents a paginated response of debug sessions
type Environment ¶ added in v1.6.0
func GetEnvironmentsForProject ¶ added in v1.6.0
type ErrAlreadyExists ¶
type ErrAlreadyExists struct {
// contains filtered or unexported fields
}
func NewErrAlreadyExists ¶ added in v1.13.0
func NewErrAlreadyExists(kind, key string) ErrAlreadyExists
func (ErrAlreadyExists) Error ¶ added in v1.13.0
func (e ErrAlreadyExists) Error() string
type ErrNotFound ¶
type ErrNotFound struct {
// contains filtered or unexported fields
}
func NewErrNotFound ¶ added in v1.13.0
func NewErrNotFound(kind, key string) ErrNotFound
func (ErrNotFound) Error ¶ added in v1.13.0
func (e ErrNotFound) Error() string
type Event ¶ added in v1.18.0
type Event struct {
ID int64 `json:"id"`
WrittenAt time.Time `json:"written_at"`
Kind string `json:"kind"`
Data json.RawMessage `json:"data"`
}
Event represents a stored event with metadata
type EventStore ¶ added in v1.18.0
type EventStore interface {
CreateDebugSession(ctx context.Context, debugSessionKey string) error
WriteEvent(ctx context.Context, debugSessionKey string, kind string, data json.RawMessage) error
QueryEvents(ctx context.Context, debugSessionKey string, kind *string, limit int, offset int) (*EventsPage, error)
QueryDebugSessions(ctx context.Context, limit int, offset int) (*DebugSessionsPage, error)
DeleteDebugSession(ctx context.Context, debugSessionKey string) error
}
func EventStoreFromContext ¶ added in v1.18.0
func EventStoreFromContext(ctx context.Context) EventStore
type EventsPage ¶ added in v1.18.0
type EventsPage struct {
Events []Event `json:"events"`
TotalCount int64 `json:"total_count"`
HasMore bool `json:"has_more"`
}
EventsPage represents a paginated response of events
type FlagVariation ¶ added in v1.5.0
type FlagsState ¶
func FromAllFlags ¶
func FromAllFlags(sdkFlags flagstate.AllFlags) FlagsState
type InitialProjectSettings ¶ added in v1.9.0
type Observers ¶
type Observers struct {
// contains filtered or unexported fields
}
func GetObserversFromContext ¶
func NewObservers ¶
func NewObservers() *Observers
func (*Observers) DeregisterObserver ¶
type Override ¶
type Override struct {
ProjectKey string
FlagKey string
Value ldvalue.Value
Active bool
Version int
}
func UpsertOverride ¶
type OverrideEvent ¶ added in v1.8.1
Event for individual flag overrides
type Project ¶
type Project struct {
Key string
SourceEnvironmentKey string
Context ldcontext.Context
LastSyncTime time.Time
AllFlagsState FlagsState
AvailableVariations []FlagVariation
}
func CreateProject ¶
func CreateProject(ctx context.Context, projectKey, sourceEnvironmentKey string, ldCtx *ldcontext.Context) (Project, error)
CreateProject creates a project and adds it to the database.
func UpdateProject ¶
func (Project) GetFlagStateWithOverridesForProject ¶
func (project Project) GetFlagStateWithOverridesForProject(ctx context.Context) (FlagsState, error)
type Store ¶
type Store interface {
// DeactivateOverride deactivates the override for the flag, returning the updated version of the override.
// ErrNotFound is returned if there isn't an override for the flag.
DeactivateOverride(ctx context.Context, projectKey, flagKey string) (int, error)
GetDevProjectKeys(ctx context.Context) ([]string, error)
// GetDevProject fetches the project based on the projectKey. If it doesn't exist, ErrNotFound is returned
GetDevProject(ctx context.Context, projectKey string) (*Project, error)
UpdateProject(ctx context.Context, project Project) (bool, error)
DeleteDevProject(ctx context.Context, projectKey string) (bool, error)
// InsertProject inserts the project. If it already exists, ErrAlreadyExists is returned
InsertProject(ctx context.Context, project Project) error
UpsertOverride(ctx context.Context, override Override) (Override, error)
GetOverridesForProject(ctx context.Context, projectKey string) (Overrides, error)
GetAvailableVariationsForProject(ctx context.Context, projectKey string) (map[string][]Variation, error)
CreateBackup(ctx context.Context) (io.ReadCloser, int64, error)
RestoreBackup(ctx context.Context, stream io.Reader) (string, error)
}
func StoreFromContext ¶
type SyncEvent ¶
type SyncEvent struct {
ProjectKey string
AllFlagsState FlagsState
}
Event for full project sync
Source Files
¶
Click to show internal directories.
Click to hide internal directories.