config

package
v0.0.0-...-c0e9d1d Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateHistory

func AnnotateHistory(entries *[]*ConfigDiffVersionHistoryEntry)

func CreateConfigCommand

func CreateConfigCommand(db *gorm.DB) *cli.Command

func CreateConfigSchemaAddCommand

func CreateConfigSchemaAddCommand(db *gorm.DB) *cli.Command

func CreateConfigSchemaCommand

func CreateConfigSchemaCommand(db *gorm.DB) *cli.Command

Types

type CommitKind

type CommitKind string
const (
	// Add more later
	CommitKindConfigDataObject CommitKind = "config_data_object"
)

type CommitORM

type CommitORM struct {
	util.ImmutableEmbed `json:",inline"`
	CommitObject        `json:"commit_object"`
}

type CommitObject

type CommitObject struct {
	CommitKind       CommitKind        `json:"commit_kind"`
	ConfigDataObject *ConfigDataObject `json:"data_object"`
}

func (*CommitObject) Scan

func (o *CommitObject) Scan(src interface{}) error

func (*CommitObject) Value

func (o *CommitObject) Value() (driver.Value, error)

type ConfigContextHandle

type ConfigContextHandle interface {
	SetData(ctx context.Context, tx *gorm.DB, cdo *ConfigDataObject, data util.Data) error
}

type ConfigContextService

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

func NewConfigContextService

func NewConfigContextService(db *gorm.DB, rdb *redis.Client, cacheService *util.CacheService) *ConfigContextService

func (*ConfigContextService) CreateHandle

func (s *ConfigContextService) CreateHandle(scope util.ScopeKind, accountId util.AccountId, userId util.UserId) ConfigContextHandle

func (*ConfigContextService) GetAccountRoot

func (s *ConfigContextService) GetAccountRoot(handle ConfigContextHandle) *ConfigVersionRef

func (*ConfigContextService) GetCurrent

func (*ConfigContextService) GetUserRoot

func (*ConfigContextService) LoadContext

func (s *ConfigContextService) LoadContext(ctx context.Context, tx *gorm.DB, handle ConfigContextHandle) error

func (*ConfigContextService) Save

func (*ConfigContextService) SetAccountRoot

func (s *ConfigContextService) SetAccountRoot(handle ConfigContextHandle, ref *ConfigVersionRef) bool

func (*ConfigContextService) SetCurrent

func (s *ConfigContextService) SetCurrent(handle ConfigContextHandle, parentRef *ConfigVersionRef, ref *ConfigVersionRef) bool

func (*ConfigContextService) SetUserRoot

func (s *ConfigContextService) SetUserRoot(handle ConfigContextHandle, ref *ConfigVersionRef) bool

type ConfigDagNode

type ConfigDagNode interface {
	GetConfigDagNode() *ConfigDagNodeEmbed
}

type ConfigDagNodeEmbed

type ConfigDagNodeEmbed struct {
	AccountId       util.AccountId       `json:"account_id" gorm:"index;not null"`
	UserId          *util.UserId         `json:"user_id" gorm:"index;null"`
	ConfigVersionId util.ConfigVersionId `json:"config_version_id" gorm:"id;primaryKey"`

	// Git like DAG
	NodeKind   ConfigDagNodeKind       `json:"node_kind"`
	Hash       util.ConfigVersionHash  `json:"config_version_hash"`
	ParentId   *util.ConfigVersionId   `json:"parent_id"`
	ParentHash *util.ConfigVersionHash `json:"parent_hash"`

	Note string `json:"note"`

	// AdditionalParents []ParentRef             `json:"additional_parents"`
	Data *ConfigDataObject `json:"data" gorm:"type:jsonb"`
}

type ConfigDagNodeKind

type ConfigDagNodeKind string
const (
	ConfigDagNodeKindRoot         ConfigDagNodeKind = "root"
	ConfigDagNodeKindData         ConfigDagNodeKind = "data"
	ConfigDagNodeKindRecordChange ConfigDagNodeKind = "record_change"
)

type ConfigDagService

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

func NewConfigDagService

func NewConfigDagService(db *gorm.DB, rdb *redis.Client, cacheService *util.CacheService, refService *ConfigReferenceService) *ConfigDagService

func (*ConfigDagService) CommitNode

func (s *ConfigDagService) CommitNode(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, node *ConfigNode) error

func (*ConfigDagService) CreateNode

func (s *ConfigDagService) CreateNode(scope util.ScopeKind, accountId util.AccountId, userId util.UserId, nodeKind ConfigNodeKind, data *util.Data, prevNode *ConfigNode) (*ConfigNode, error)

func (*ConfigDagService) GetExistingNode

func (s *ConfigDagService) GetExistingNode(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId *util.UserId, queryFuncs ...ConfigQueryFunc) (*ConfigNodeORM, error)

func (*ConfigDagService) GetReferences

func (s *ConfigDagService) GetReferences(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId) (RefMap, error)

type ConfigDataObject

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

func NewConfigDataObject

func NewConfigDataObject() *ConfigDataObject

func (*ConfigDataObject) GetConfigData

func (c *ConfigDataObject) GetConfigData() util.Data

func (*ConfigDataObject) GetConfigParentVersionRef

func (c *ConfigDataObject) GetConfigParentVersionRef() *ConfigVersionRef

func (*ConfigDataObject) GetConfigVersionRef

func (c *ConfigDataObject) GetConfigVersionRef() *ConfigVersionRef

func (*ConfigDataObject) MarshalJSON

func (c *ConfigDataObject) MarshalJSON() ([]byte, error)

Allow marshalling and unmarshalling of the inner data object

func (*ConfigDataObject) Scan

func (c *ConfigDataObject) Scan(src interface{}) error

func (*ConfigDataObject) UnmarshalJSON

func (c *ConfigDataObject) UnmarshalJSON(data []byte) error

func (ConfigDataObject) Value

func (c ConfigDataObject) Value() (driver.Value, error)

type ConfigDataObjectEmbed

type ConfigDataObjectEmbed struct {
	// ConfigDataObject `json:",inline" gorm:"config_data_object;type:jsonb;not null"`
	ConfigDataObject ConfigDataObject `json:",inline" gorm:"embedded"`
}

type ConfigDataRecord

type ConfigDataRecord util.Data

type ConfigDiffParams

type ConfigDiffParams struct {
	From *ConfigDiffSpec
	To   *ConfigDiffSpec

	IncludeObject              bool
	IncludePreviousObject      bool
	IncludeNodeContentsPatch   bool
	IncludeRecordMetadataPatch bool
	IncludeRecordContentsPatch bool

	IncludeRecord bool

	OnlyMatching bool

	// RecordMatchFilter *RecordMatchFilter
	ConfigRecordQuery *ConfigRecordQuery

	OnlyLatest bool
}

type ConfigDiffService

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

func NewConfigDiffService

func NewConfigDiffService(db *gorm.DB, rdb *redis.Client, cacheService *util.CacheService, dagService *ConfigDagService, refService *ConfigReferenceService) *ConfigDiffService

func (*ConfigDiffService) GetLatestRecord

func (s *ConfigDiffService) GetLatestRecord(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, fromVersion *ConfigVersionRef, toVersion *ConfigVersionRef, recordQuery *ConfigRecordQuery) (*ConfigDiffVersion, error)

func (*ConfigDiffService) GetVersionChain

func (s *ConfigDiffService) GetVersionChain(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, params *ConfigDiffParams) (*ConfigDiffVersions, error)

type ConfigDiffSpec

type ConfigDiffSpec struct {
	Version *ConfigVersionRef `json:"version"`
}

type ConfigDiffVersion

type ConfigDiffVersion struct {
	FromVersion *ConfigVersionRef `json:"from_version"`
	ToVersion   *ConfigVersionRef `json:"to_version"`
	Match       bool              `json:"match"`

	NodeContents   *util.Data            `json:"object,omitempty"`
	RecordMetadata *ConfigRecordMetadata `json:"record_metadata,omitempty"`
	RecordContents *util.Data            `json:"record_contents,omitempty"`
	RecordHistory  []*ConfigDiffVersionHistoryEntry

	NodeContentsPatch   *jsondiff.Patch `json:"diff"`
	RecordMetadataPatch *jsondiff.Patch `json:"record_metadata_diff"`
	RecordContentsPatch *jsondiff.Patch `json:"record_diff"`

	// Temporary
	PrevObject *util.Data `json:"prev_object,omitempty"`
}

func (*ConfigDiffVersion) DecodeRecordContents

func (v *ConfigDiffVersion) DecodeRecordContents(dest interface{}) error

type ConfigDiffVersionHistoryEntry

type ConfigDiffVersionHistoryEntry struct {
	RecordContents       *util.Data                `json:"record_contents"`
	RecordCollectionKey  *util.ConfigCollectionKey `json:"record_collection_key"`
	RecordItemKey        *util.ConfigItemKey       `json:"record_item_key"`
	ConfigRecordMetadata *ConfigRecordMetadata     `json:"config_record_metadata"`
	NodeMetadata         *ConfigNodeMetadata       `json:"node_metadata"`
	// ConfigVersionHash       *util.ConfigVersionHash   `json:"config_version_hash"`
	RecordContentsPatch     *jsondiff.Patch `json:"record_diff"`
	RecordContentsTextPatch string          `json:"record_diff_text"`
}

type ConfigDiffVersions

type ConfigDiffVersions struct {
	FromVersion *ConfigVersionRef          `json:"from_version"`
	ToVersion   *ConfigVersionRef          `json:"to_version"`
	Versions    []ConfigDiffVersion        `json:"versions"`
	ListHash    *util.ConfigSchemaListHash `json:"list_hash"`
}

type ConfigDocumentORM

type ConfigDocumentORM struct {
	ConfigDocumentKey util.ConfigDocumentKey `json:"config_document_key" gorm:"type:text;not null"`
	ConfigDocumentId  util.ConfigDocumentId  `json:"config_document_id" gorm:"type:text;not null"`

	// ConfigImmutableDataEmbed `json:",inline" gorm:"embedded"`
	// ConfigImmutableDataEmbed `json:",inline" gorm:"-"`
	// ConfigImmutableDataEmbed `json:",inline" ` //gorm:"-"`
	ConfigImmutableDataEmbed `json:",inline"`
}

func (*ConfigDocumentORM) AddIndexes

func (c *ConfigDocumentORM) AddIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigDocumentORM) GetConfigDataObject

func (c *ConfigDocumentORM) GetConfigDataObject() *ConfigDataObject

func (*ConfigDocumentORM) RemoveIndexes

func (c *ConfigDocumentORM) RemoveIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigDocumentORM) SetRecordConfigData

func (c *ConfigDocumentORM) SetRecordConfigData(ctx context.Context, tx *gorm.DB, data util.Data, handle ConfigContextHandle) error

func (*ConfigDocumentORM) TableName

func (c *ConfigDocumentORM) TableName() string

type ConfigDocumentRecord

type ConfigDocumentRecord util.Data

type ConfigGormQuerier

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

func (*ConfigGormQuerier) Querier

func (q *ConfigGormQuerier) Querier() *gorm.DB

func (*ConfigGormQuerier) Where

func (q *ConfigGormQuerier) Where(cond interface{}, params ...interface{}) ConfigQuerier

type ConfigImmutableDataEmbed

type ConfigImmutableDataEmbed struct {
	AccountId util.AccountId `json:"account_id" gorm:"not null"`
	UserId    *util.UserId   `json:"user_id" gorm:""`
	CreatedAt time.Time      `json:"created_at"`
	CreatedBy *util.UserId   `json:"created_by" gorm:""`
	DeletedAt *time.Time     `json:"deleted_at"`

	// ConfigImmutableEmbedOld `json:",inline" gorm:"embedded"`
	// ConfigDataObject `json:",inline" gorm:"config_data_object;type:jsonb"`
	// ConfigDataObject `json:",inline" gorm:"config_data_object"`
	// ConfigDataObject `json:",inline" gorm:"-"`
	// ConfigDataObject `json:",inline" gorm:"embedded;type:jsonb"`
	// ConfigDataObject `json:",inline"`
	ConfigDataObjectEmbed `json:",inline"`
}

func (*ConfigImmutableDataEmbed) AddDataIndexes

func (c *ConfigImmutableDataEmbed) AddDataIndexes(ctx context.Context, tx *sql.Tx, tableName string, fields ...string) error

func (*ConfigImmutableDataEmbed) GetConfigDataObject

func (c *ConfigImmutableDataEmbed) GetConfigDataObject() *ConfigDataObject

func (*ConfigImmutableDataEmbed) RemoveDataIndexes

func (c *ConfigImmutableDataEmbed) RemoveDataIndexes(ctx context.Context, tx *sql.Tx, tableName string) error

type ConfigKeyedDataORM

type ConfigKeyedDataORM struct {
	ConfigKey util.ConfigKey `json:"config_key" gorm:"type:text;not null"`

	ConfigImmutableDataEmbed `json:",inline"`
}

func (*ConfigKeyedDataORM) AddIndexes

func (c *ConfigKeyedDataORM) AddIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigKeyedDataORM) GetConfigDataObject

func (c *ConfigKeyedDataORM) GetConfigDataObject() *ConfigDataObject

func (*ConfigKeyedDataORM) RemoveIndexes

func (c *ConfigKeyedDataORM) RemoveIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigKeyedDataORM) SetRecordConfigData

func (c *ConfigKeyedDataORM) SetRecordConfigData(ctx context.Context, tx *gorm.DB, data util.Data, handle ConfigContextHandle) error

func (*ConfigKeyedDataORM) TableName

func (c *ConfigKeyedDataORM) TableName() string

type ConfigKeyedRecord

type ConfigKeyedRecord util.Data

type ConfigKeyedRecordObject

type ConfigKeyedRecordObject struct {
	ConfigRecordObject
}

type ConfigListEntry

type ConfigListEntry struct {
	RecordKey           *util.ConfigRecordKey            `json:"id"`
	RecordKind          *ConfigRecordKind                `json:"record_kind"`
	RecordId            *util.ConfigRecordId             `json:"record_id"`
	RecordCollectionKey *util.ConfigCollectionKey        `json:"record_collection_key"`
	RecordItemKey       *util.ConfigItemKey              `json:"record_item_key"`
	NodeMetadata        *ConfigNodeMetadata              `json:"node_metadata"`
	RecordContents      *util.Data                       `json:"record_contents"`
	RecordHistory       []*ConfigDiffVersionHistoryEntry `json:"record_history"`
}

func (*ConfigListEntry) String

func (e *ConfigListEntry) String() string

type ConfigMetadata

type ConfigMetadata struct {
	CreatedAt time.Time `json:"created_at"`
	// TODO: Make this non-optional and always pass the user id
	// use ScopeKind to determine if it's an account or user scope
	CreatedBy *util.UserId `json:"created_by"`

	VersionRef ConfigVersionRef  `json:"version_ref"`
	ParentRef  *ConfigVersionRef `json:"parent_ref"`
}

type ConfigModelFunc

type ConfigModelFunc func() ConfigRecordModel

type ConfigNode

type ConfigNode struct {
	NodeMetadata ConfigNodeMetadata `json:"node_metadata" gorm:"column:node_metadata;type:jsonb;not null"`
	Contents     *util.Data         `json:"node_contents" gorm:"column:node_contents;type:jsonb"`
}

func NewConfigNode

func NewConfigNode(kind ConfigNodeKind, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, parentRef *ConfigVersionRef, contents *util.Data) (*ConfigNode, error)

func (*ConfigNode) AsRecord

func (c *ConfigNode) AsRecord() *ConfigRecordObject

func (*ConfigNode) ComputeHash

func (c *ConfigNode) ComputeHash() (*util.ConfigVersionHash, error)

func (*ConfigNode) DecodeContents

func (c *ConfigNode) DecodeContents(dest interface{}) error

func (*ConfigNode) EncodeContents

func (c *ConfigNode) EncodeContents(src interface{}) error

func (*ConfigNode) GetConfigVersionRef

func (c *ConfigNode) GetConfigVersionRef() *ConfigVersionRef

func (*ConfigNode) GetContents

func (c *ConfigNode) GetContents() *util.Data

func (*ConfigNode) GetNodeMetadata

func (c *ConfigNode) GetNodeMetadata() *ConfigNodeMetadata

func (*ConfigNode) GetParentRef

func (c *ConfigNode) GetParentRef() *ConfigVersionRef

func (*ConfigNode) GetRecordContents

func (c *ConfigNode) GetRecordContents() *util.Data

func (*ConfigNode) GetVersionRef

func (c *ConfigNode) GetVersionRef() *ConfigVersionRef

func (*ConfigNode) ParseNode

func (c *ConfigNode) ParseNode() (interface{}, error)

func (*ConfigNode) SetContents

func (c *ConfigNode) SetContents(contents *util.Data) error

type ConfigNodeKind

type ConfigNodeKind string
const (
	// Used as a placeholder for a branch with no commits
	ConfigNodeKindEmpty  ConfigNodeKind = "empty"
	ConfigNodeKindData   ConfigNodeKind = "data"
	ConfigNodeKindRecord ConfigNodeKind = "record"
)

type ConfigNodeMetadata

type ConfigNodeMetadata struct {
	NodeKind    ConfigNodeKind    `json:"node_kind" gorm:"type:text;not null"`
	Scope       util.ScopeKind    `json:"scope" gorm:"type:text;not null"`
	AccountId   util.AccountId    `json:"account_id" gorm:"type:text;not null"`
	UserId      util.UserId       `json:"user_id" gorm:"type:text"`
	CreatedAt   time.Time         `json:"created_at" gorm:"type:timestamp with time zone;not null"`
	CreatedBy   util.UserId       `json:"created_by" gorm:"type:text"`
	CommittedAt *time.Time        `json:"committed_at" gorm:"index;type:timestamp with time zone"`
	CommittedBy *util.UserId      `json:"committed_by" gorm:"index;type:text"`
	VersionRef  ConfigVersionRef  `json:"version_ref" gorm:"type:jsonb;not null"`
	ParentRef   *ConfigVersionRef `json:"parent_ref" gorm:"type:jsonb"`
}

type ConfigNodeORM

type ConfigNodeORM struct {
	util.ImmutableEmbed `json:",inline"`
	ConfigNode
}

func (*ConfigNodeORM) AddConstraints

func (m *ConfigNodeORM) AddConstraints(ctx context.Context, tx *sql.Tx) error

func (*ConfigNodeORM) AddIndexes

func (m *ConfigNodeORM) AddIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigNodeORM) GetConfigNode

func (c *ConfigNodeORM) GetConfigNode() *ConfigNode

func (*ConfigNodeORM) RemoveConstraints

func (m *ConfigNodeORM) RemoveConstraints(ctx context.Context, tx *sql.Tx) error

func (*ConfigNodeORM) RemoveIndexes

func (m *ConfigNodeORM) RemoveIndexes(ctx context.Context, tx *sql.Tx) error

func (ConfigNodeORM) TableName

func (c ConfigNodeORM) TableName() string

type ConfigORM

type ConfigORM struct {
	Id        string         `json:"id" gorm:"primaryKey"`
	AccountId util.AccountId `json:"account_id" gorm:"index;not null"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt *time.Time     `json:"deleted_at"`
	CreatedBy *util.UserId   `json:"created_by" gorm:"index"`
}

func (*ConfigORM) TableName

func (c *ConfigORM) TableName() string

type ConfigQuerier

type ConfigQuerier interface {
	Where(cond interface{}, params ...interface{}) ConfigQuerier
}

type ConfigQueryFunc

type ConfigQueryFunc func(querier ConfigQuerier) ConfigQuerier

func ConfigRecordQueryFunc

func ConfigRecordQueryFunc(recordQuery ConfigRecordQuery) ConfigQueryFunc

func ConfigRefQueryFunc

func ConfigRefQueryFunc(versionRef ConfigVersionRef) ConfigQueryFunc

type ConfigQueryValues

type ConfigQueryValues map[string]interface{}

type ConfigRecordKind

type ConfigRecordKind string
const (
	ConfigRecordKindData                    ConfigRecordKind = "data"
	ConfigRecordKindKeyed                   ConfigRecordKind = "keyed"
	ConfigRecordKindDocument                ConfigRecordKind = "document"
	ConfigRecordKindConfigSchema            ConfigRecordKind = "config_schema"
	ConfigRecordKindConfigSchemaAssociation ConfigRecordKind = "config_schema_association"
)

func ConfigRecordKindAsPtr

func ConfigRecordKindAsPtr(kind ConfigRecordKind) *ConfigRecordKind

type ConfigRecordMetadata

type ConfigRecordMetadata struct {
	RecordId      util.ConfigRecordId      `json:"record_id"`
	CollectionKey util.ConfigCollectionKey `json:"record_collection_key"`
	ItemKey       *util.ConfigItemKey      `json:"record_item_key"`
	RecordKind    *ConfigRecordKind        `json:"record_kind"`
}

func (*ConfigRecordMetadata) AsRecordQuery

func (m *ConfigRecordMetadata) AsRecordQuery() *ConfigRecordQuery

type ConfigRecordModel

type ConfigRecordModel interface {
	// Gorm methods
	TableName() string

	GetConfigDataObject() *ConfigDataObject
}

type ConfigRecordNode

type ConfigRecordNode struct {
	RecordMetadata ConfigRecordMetadata `json:"record_metadata" gorm:"column:record_metadata;type:jsonb;not null"`
	RecordContents util.Data            `json:"record_contents" gorm:"column:record_contents;type:jsonb"`
}

func ToRecordNode

func ToRecordNode(data util.Data) (*ConfigRecordNode, error)

func (*ConfigRecordNode) ParseRecord

func (n *ConfigRecordNode) ParseRecord() (*ConfigRecordKind, interface{}, error)

type ConfigRecordORM

type ConfigRecordORM struct {
	util.ImmutableEmbed `json:",inline"`
	ConfigRecordObject  `json:"config_record_object"`
}

func (*ConfigRecordORM) AddIndexes

func (c *ConfigRecordORM) AddIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigRecordORM) RemoveIndexes

func (c *ConfigRecordORM) RemoveIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigRecordORM) TableName

func (c *ConfigRecordORM) TableName() string

type ConfigRecordObject

type ConfigRecordObject struct {
	ConfigRecordKind ConfigRecordKind `json:"record_kind"`

	RecordMetadata ConfigRecordMetadata `json:"record_metadata" gorm:"column:record_metadata;type:jsonb;not null"`
	Contents       util.Data            `json:"record_contents" gorm:"column:record_contents;type:jsonb"`
}

func (*ConfigRecordObject) AsDataMap

func (c *ConfigRecordObject) AsDataMap() (*util.Data, bool)

func (*ConfigRecordObject) DecodeContents

func (c *ConfigRecordObject) DecodeContents(dest interface{}) error

func (*ConfigRecordObject) EncodeContents

func (c *ConfigRecordObject) EncodeContents(src interface{}) error

type ConfigRecordQuery

type ConfigRecordQuery struct {
	Scope             *util.ScopeKind           `json:"scope_kind"`
	AccountId         *util.AccountId           `json:"account_id"`
	UserId            *util.UserId              `json:"user_id"`
	RecordKind        *ConfigRecordKind         `json:"record_kind"`
	RecordId          *util.ConfigRecordId      `json:"record_id"`
	CollectionKey     *util.ConfigCollectionKey `json:"collection_key"`
	ItemKey           *util.ConfigItemKey       `json:"item_key"`
	ConfigVersionHash *util.ConfigVersionHash   `json:"config_version_hash"`
}

func (*ConfigRecordQuery) AsMatchFilter

func (q *ConfigRecordQuery) AsMatchFilter() *RecordMatchFilter

func (*ConfigRecordQuery) AsMetadata

func (q *ConfigRecordQuery) AsMetadata() *ConfigRecordMetadata

func (*ConfigRecordQuery) PopulateMatchFilter

func (q *ConfigRecordQuery) PopulateMatchFilter(filter *RecordMatchFilter)

type ConfigReferenceKind

type ConfigReferenceKind string
const (
	ConfigReferenceKindRoot ConfigReferenceKind = "root"
	ConfigReferenceKindHead ConfigReferenceKind = "head"

	// The earliest version of the config for the given stage
	ConfigReferenceKindStageRoot   ConfigReferenceKind = "stage_root"
	ConfigReferenceKindTaggedStage ConfigReferenceKind = "tagged_stage"
	ConfigReferenceKindTag         ConfigReferenceKind = "tag"
)

type ConfigReferenceORM

type ConfigReferenceORM struct {
	Scope     util.ScopeKind `json:"scope" gorm:"uniqueIndex:ref_unique;not null"`
	AccountId util.AccountId `json:"account_id" gorm:"uniqueIndex:ref_unique;not null"`
	UserId    *util.UserId   `json:"user_id" gorm:"uniqueIndex:ref_unique"`

	ConfigReferenceKind ConfigReferenceKind `json:"reference_kind" gorm:"uniqueIndex:ref_unique;not null"`

	VersionRef *ConfigVersionRef `json:"version_ref" gorm:"type:jsonb;not null"`
}

func (*ConfigReferenceORM) AddConstraints

func (c *ConfigReferenceORM) AddConstraints(ctx context.Context, tx *sql.Tx) error

func (*ConfigReferenceORM) AddIndexes

func (c *ConfigReferenceORM) AddIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigReferenceORM) RemoveConstraints

func (c *ConfigReferenceORM) RemoveConstraints(ctx context.Context, tx *sql.Tx) error

func (*ConfigReferenceORM) RemoveIndexes

func (c *ConfigReferenceORM) RemoveIndexes(ctx context.Context, tx *sql.Tx) error

func (*ConfigReferenceORM) TableName

func (c *ConfigReferenceORM) TableName() string

type ConfigReferenceResult

type ConfigReferenceResult struct {
	CurrentRef *ConfigVersionRef `json:"current_ref"`
	ParentRef  *ConfigVersionRef `json:"parent_ref"`
}

type ConfigReferenceService

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

func NewConfigReferenceService

func NewConfigReferenceService(db *gorm.DB, rdb *redis.Client, cacheService *util.CacheService) *ConfigReferenceService

func (*ConfigReferenceService) GetConfigReference

func (s *ConfigReferenceService) GetConfigReference(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, kind ConfigReferenceKind) (*configRefCache, error)

func (*ConfigReferenceService) GetRecord

func (*ConfigReferenceService) SetConfigReference

func (s *ConfigReferenceService) SetConfigReference(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, kind ConfigReferenceKind, ref *ConfigVersionRef) error

type ConfigResourceData

type ConfigResourceData map[string]interface{}

type ConfigSchemaAssociationRecord

type ConfigSchemaAssociationRecord struct {
	SchemaHash    *util.ConfigSchemaHash    `json:"schema_hash" gorm:"column:schema_hash;type:varchar(64);not null"`
	SchemaIdValue *util.ConfigSchemaIdValue `json:"schema_id_value" gorm:"column:schema_id_value;type:varchar(64);not null"`
	SchemaRef     *ConfigVersionRef         `json:"schema_ref" gorm:"column:schema_ref;type:jsonb;not null"`
}

type ConfigSchemaMigrations

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

func NewConfigSchemaMigrations

func NewConfigSchemaMigrations(db *gorm.DB) *ConfigSchemaMigrations

func (*ConfigSchemaMigrations) AddSchema

func (m *ConfigSchemaMigrations) AddSchema(ctx context.Context, params *cmdAddConfigSchemaParams) error

func (*ConfigSchemaMigrations) AddSchemas

func (m *ConfigSchemaMigrations) AddSchemas(ctx context.Context, params *cmdAddConfigSchemaParams) error

type ConfigSchemaObject

type ConfigSchemaObject struct {
	SchemaName     *util.ConfigSchemaName     `json:"schema_name"`
	SchemaIdValue  *util.ConfigSchemaIdValue  `json:"schema_id_value"`
	SchemaContents *util.ConfigSchemaContents `json:"schema_contents"`
}

type ConfigSchemaRecord

type ConfigSchemaRecord struct {
	SchemaHash     *util.ConfigVersionHash   `json:"schema_hash" gorm:"column:schema_hash;type:varchar(64);not null"`
	SchemaName     *util.ConfigSchemaName    `json:"schema_name" gorm:"column:schema_name;type:varchar(64);not null"`
	SchemaIdValue  *util.ConfigSchemaIdValue `json:"schema_id_value" gorm:"column:schema_id_value;type:varchar(64);not null"`
	SchemaContents util.ConfigSchemaContents `json:"schema_contents" gorm:"column:schema_contents;type:jsonb"`
}

type ConfigSchemaService

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

func NewConfigSchemaService

func NewConfigSchemaService(db *gorm.DB, rdb *redis.Client, configService *ConfigService) *ConfigSchemaService

func (*ConfigSchemaService) GetConfigSchemaVersions

func (s *ConfigSchemaService) GetConfigSchemaVersions(ctx context.Context, tx *gorm.DB, schemaQuery *ConfigRecordQuery) (*ConfigSchemaVersions, error)

func (*ConfigSchemaService) GetLatestSchemaVersion

func (s *ConfigSchemaService) GetLatestSchemaVersion(ctx context.Context, tx *gorm.DB, schemaQuery *ConfigRecordQuery) (*ConfigSchemaRecord, error)

func (*ConfigSchemaService) GetSchema

func (s *ConfigSchemaService) GetSchema(ctx context.Context, tx *gorm.DB, schemaQuery *ConfigRecordQuery) (*ConfigSchemaRecord, error)

type ConfigSchemaVersions

type ConfigSchemaVersions struct {
	Versions []*ConfigSchemaRecord `json:"versions"`
	ListHash string                `json:"list_hash"`
}

type ConfigService

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

func NewConfigService

func NewConfigService(db *gorm.DB, rdb *redis.Client, cacheService *util.CacheService) *ConfigService

func (*ConfigService) CommitNode

func (s *ConfigService) CommitNode(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, node *ConfigNode) error

func (*ConfigService) CreateNode

func (s *ConfigService) CreateNode(scope util.ScopeKind, accountId util.AccountId, userId util.UserId, nodeKind ConfigNodeKind, data *util.Data, prevNode *ConfigNode) (*ConfigNode, error)

func (*ConfigService) GetConfigContextService

func (s *ConfigService) GetConfigContextService() *ConfigContextService

func (*ConfigService) GetConfigDagService

func (s *ConfigService) GetConfigDagService() *ConfigDagService

func (*ConfigService) GetConfigDiffService

func (s *ConfigService) GetConfigDiffService() *ConfigDiffService

func (*ConfigService) GetConfigSchemaService

func (s *ConfigService) GetConfigSchemaService() *ConfigSchemaService

func (*ConfigService) GetLatestRecord

func (s *ConfigService) GetLatestRecord(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, fromVersion *ConfigVersionRef, toVersion *ConfigVersionRef, recordQuery *ConfigRecordQuery) (*ConfigDiffVersion, error)

func (*ConfigService) InsertRecord

func (s *ConfigService) InsertRecord(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, recordMetadata *ConfigRecordMetadata, recordObject interface{}) (*ConfigNodeMetadata, error)

func (*ConfigService) ListConfigs

func (s *ConfigService) ListConfigs(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, recordQuery *ConfigRecordQuery) ([]*ConfigListEntry, error)

func (*ConfigService) SetRecordValues

func (s *ConfigService) SetRecordValues(ctx context.Context, tx *gorm.DB, scope util.ScopeKind, accountId util.AccountId, userId util.UserId, kind ConfigRecordKind, recordMetadata *ConfigRecordMetadata, mode ValueSettingMode, values *util.Data) (*ConfigNodeMetadata, error)

type ConfigSettingHandle

type ConfigSettingHandle ConfigContextHandle

TODO: Remove

type ConfigStageAudienceKind

type ConfigStageAudienceKind string
const (
	ConfigStageAudienceKindClient    ConfigStageAudienceKind = "client"
	ConfigStageAudienceKindMarketing ConfigStageAudienceKind = "marketing"
	ConfigStageAudienceKindInternal  ConfigStageAudienceKind = "internal"
	ConfigStageAudienceKindPartner   ConfigStageAudienceKind = "partner"
	ConfigStageAudienceKindTest      ConfigStageAudienceKind = "test"
	ConfigStageAudienceKindDev       ConfigStageAudienceKind = "dev"
	ConfigStageAudienceKindOther     ConfigStageAudienceKind = "other"
)

type ConfigStageKind

type ConfigStageKind string
const (
	ConfigStageKindProd             ConfigStageKind = "prod"
	ConfigStageKindBeta             ConfigStageKind = "beta"
	ConfigStageKindClientValidation ConfigStageKind = "client_validation"
	ConfigStageKindTest             ConfigStageKind = "test"
	ConfigStageKindDev              ConfigStageKind = "dev"
)

type ConfigTagORM

type ConfigTagORM struct {
	ConfigTagObject `json:",inline" gorm:"embedded"`
}

func (*ConfigTagORM) TableName

func (c *ConfigTagORM) TableName() string

type ConfigTagObject

type ConfigTagObject struct {
	AccountId util.AccountId `json:"account_id" gorm:"uniqueIndex:config_tag_object_tag;not null"`
	UserId    *util.UserId   `json:"user_id" gorm:"uniqueIndex:config_tag_object_tag;null"`

	Tag        string            `json:"tag" gorm:"uniqueIndex:config_tag_object_tag;not null"`
	VersionRef *ConfigVersionRef `json:"version_ref"`

	ConfigReferenceKind     *ConfigReferenceKind     `json:"config_reference_kind" gorm:"index"`
	ConfigStageAudienceKind *ConfigStageAudienceKind `json:"config_stage_audience_kind" gorm:"index"`
	ConfigStageKind         *ConfigStageKind         `json:"config_stage_kind" gorm:"index"`
}

type ConfigVersionORM

type ConfigVersionORM struct {
	Id util.ConfigVersionId `json:"id"`

	ConfigDagNodeEmbed `json:",inline" gorm:"embedded"`
}

func (*ConfigVersionORM) TableName

func (c *ConfigVersionORM) TableName() string

type ConfigVersionRef

type ConfigVersionRef struct {
	Scope             util.ScopeKind         `json:"scope" gorm:"index;not null"`
	AccountId         util.AccountId         `json:"account_id" gorm:"index;not null"`
	UserId            *util.UserId           `json:"user_id" gorm:"index;null"`
	ConfigVersionId   util.ConfigVersionId   `json:"config_version_id" gorm:"index;not null"`
	ConfigVersionHash util.ConfigVersionHash `json:"config_version_hash" gorm:"index;not null"`
	CreatedAt         time.Time              `json:"created_at"`
	CreatedBy         util.UserId            `json:"created_by" gorm:"index;null"`
	CommittedAt       *time.Time             `json:"committed_at"`
	CommittedBy       *util.UserId           `json:"committed_by" gorm:"index;null"`
	Note              *string                `json:"note"`
}

func (*ConfigVersionRef) Scan

func (v *ConfigVersionRef) Scan(src interface{}) error

func (ConfigVersionRef) String

func (v ConfigVersionRef) String() string

func (ConfigVersionRef) Value

func (v ConfigVersionRef) Value() (driver.Value, error)

type ConfigVersions

type ConfigVersions struct {
	Versions []*ConfigRecordObject `json:"versions"`
	ListHash string                `json:"list_hash"`
}

type ConfigWhereQuery

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

func (*ConfigWhereQuery) Sql

func (q *ConfigWhereQuery) Sql() string

func (*ConfigWhereQuery) SqlAlias

func (q *ConfigWhereQuery) SqlAlias(alias string) string

func (*ConfigWhereQuery) Where

func (q *ConfigWhereQuery) Where(cond interface{}, params ...interface{}) ConfigQuerier

type DiffVersionChainEntry

type DiffVersionChainEntry struct {
	CurrentHash    *util.ConfigVersionHash          `json:"cur_hash"`
	ParentHash     *util.ConfigVersionHash          `json:"parent_hash"`
	NodeKind       *ConfigNodeKind                  `json:"node_kind"`
	NodeMetadata   *ConfigNodeMetadata              `json:"node_metadata"`
	NodeContents   *util.Data                       `json:"node_contents"`
	RecordMetadata *ConfigRecordMetadata            `json:"record_metadata"`
	RecordContents *util.Data                       `json:"record_contents"`
	RecordHistory  []*ConfigDiffVersionHistoryEntry `json:"record_history"`
	RecordMatch    bool                             `json:"record_match"`
}

func (*DiffVersionChainEntry) Scan

func (e *DiffVersionChainEntry) Scan(value interface{}) error

func (*DiffVersionChainEntry) Value

func (e *DiffVersionChainEntry) Value() (driver.Value, error)

type ErrConfigDataObjectEncodingFailed

type ErrConfigDataObjectEncodingFailed struct {
	Err error `json:"error"`
}

func NewConfigObjectEncodingFailed

func NewConfigObjectEncodingFailed(err error) *ErrConfigDataObjectEncodingFailed

func (*ErrConfigDataObjectEncodingFailed) Error

func (*ErrConfigDataObjectEncodingFailed) Unwrap

type ErrConfigObjectSettingConflict

type ErrConfigObjectSettingConflict struct {
	Err error `json:"error"`
}

ErrConfigObjectSettingConflict is returned when a conflict is detected

func NewConfigObjectSettingConflict

func NewConfigObjectSettingConflict(err error) *ErrConfigObjectSettingConflict

NewConfigObjectSettingConflict returns a new and error indicating a conflict

func (*ErrConfigObjectSettingConflict) Error

func (*ErrConfigObjectSettingConflict) Unwrap

type ErrConfigSettingError

type ErrConfigSettingError struct {
	Err error `json:"error"`
}

ErrConfigSettingError is returned when an error occurs while setting a config object or value

func NewConfigSettingError

func NewConfigSettingError(err error) *ErrConfigSettingError

func (*ErrConfigSettingError) Error

func (e *ErrConfigSettingError) Error() string

func (*ErrConfigSettingError) Unwrap

func (e *ErrConfigSettingError) Unwrap() error

type ErrConfigSettingHandleConsumed

type ErrConfigSettingHandleConsumed struct{}

func NewConfigSettingHandleConsumed

func NewConfigSettingHandleConsumed() *ErrConfigSettingHandleConsumed

func (ErrConfigSettingHandleConsumed) Error

type ErrInvalidConfigDataObjectHandle

type ErrInvalidConfigDataObjectHandle struct {
	Err error `json:"error"`
}

func NewInvalidConfigDataObjectHandle

func NewInvalidConfigDataObjectHandle(err error) *ErrInvalidConfigDataObjectHandle

func (ErrInvalidConfigDataObjectHandle) Error

type ErrInvalidConfigDiffParams

type ErrInvalidConfigDiffParams struct {
	Err error `json:"error"`
}

ErrInvalidConfigDiffParams is returned when invalid parameters are passed to the diff function

func NewInvalidConfigDiffParams

func NewInvalidConfigDiffParams(err error) *ErrInvalidConfigDiffParams

func (*ErrInvalidConfigDiffParams) Error

func (*ErrInvalidConfigDiffParams) Unwrap

func (e *ErrInvalidConfigDiffParams) Unwrap() error

type ErrInvalidConfigRecordType

type ErrInvalidConfigRecordType struct {
	Err error `json:"error"`
}

func NewInvalidConfigRecordType

func NewInvalidConfigRecordType(err error) *ErrInvalidConfigRecordType

func (ErrInvalidConfigRecordType) Error

func (ErrInvalidConfigRecordType) Unwrap

func (e ErrInvalidConfigRecordType) Unwrap() error

type ErrInvalidConfigSettingHandle

type ErrInvalidConfigSettingHandle struct {
	Err error `json:"error"`
}

func NewInvalidConfigSettingHandle

func NewInvalidConfigSettingHandle(err error) *ErrInvalidConfigSettingHandle

func (ErrInvalidConfigSettingHandle) Error

type ErrMissingRequiredParameter

type ErrMissingRequiredParameter struct {
	ParamName string `json:"param_name"`
}

func NewMissingRequiredParameter

func NewMissingRequiredParameter(name string) *ErrMissingRequiredParameter

func (*ErrMissingRequiredParameter) Error

type ErrReferenceNotFound

type ErrReferenceNotFound struct {
	Scope         util.ScopeKind      `json:"scope"`
	AccountId     util.AccountId      `json:"account_id"`
	UserId        *util.UserId        `json:"user_id"`
	ReferenceKind ConfigReferenceKind `json:"reference_kind"`
}

func NewReferenceNotFound

func NewReferenceNotFound(scope util.ScopeKind, accountId util.AccountId, userId *util.UserId, kind ConfigReferenceKind) *ErrReferenceNotFound

func (*ErrReferenceNotFound) Error

func (e *ErrReferenceNotFound) Error() string

type RecordMatchFilter

type RecordMatchFilter struct {
	Scope               *util.ScopeKind           `json:"scope"`
	AccountId           *util.AccountId           `json:"account_id"`
	UserId              *util.UserId              `json:"user_id"`
	RecordKind          *ConfigRecordKind         `json:"record_kind"`
	RecordId            *util.ConfigRecordId      `json:"record_id"`
	RecordCollectionKey *util.ConfigCollectionKey `json:"record_collection_key"`
	RecordItemKey       *util.ConfigItemKey       `json:"record_item_key"`
	OnlyMatching        bool                      `json:"only_matching"`
}

type SetRecordValuesResult

type SetRecordValuesResult struct {
	NodeMetadata ConfigNodeMetadata `json:"node_metadata"`
	NodeContents *util.Data         `json:"node_contents"`
}

type ValueSettingMode

type ValueSettingMode string
const (
	ValueSettingModeReplace   ValueSettingMode = "replace_all"
	ValueSettingModeDeepMerge ValueSettingMode = "deep_merge"
)

Jump to

Keyboard shortcuts

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