data

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileDecode

func FileDecode(encoded string) []byte

func FileEncode

func FileEncode(content []byte) string

Types

type Entity

type Entity interface {
	GetId() string
	GetType() string
	GetName() string
	GetParentId() string
	GetChildrenIds() []string

	AppendChildId(string)
	RemoveChildId(string)
	SetChildrenIds([]string)

	SetId(string)
	SetType(string)
	SetName(string)
	SetParentId(string)

	Impl() any
}

type EntityBinding

type EntityBinding interface {
	Entity

	GetField(string) FieldBinding
}

type EntityFieldValidator

type EntityFieldValidator interface {
	// RegisterEntityFields registers required fields for an entity type
	RegisterEntityFields(entityType string, fields ...string)
	// ValidateFields checks if all registered entity fields exist in the schema
	ValidateFields(context.Context) error
}

EntityFieldValidator ensures that entities and their fields exist in the schema

func NewEntityFieldValidator

func NewEntityFieldValidator(store Store) EntityFieldValidator

type EntitySchema

type EntitySchema interface {
	GetType() string
	GetFields() []FieldSchema
	GetFieldNames() []string
	GetField(string) FieldSchema

	SetType(string)
	SetFields([]FieldSchema)
}

type Field

type Field interface {
	GetValue() Value
	GetWriteTime() time.Time
	GetWriter() string
	GetEntityId() string
	GetFieldName() string
}

type FieldBinding

type FieldBinding interface {
	GetEntityId() string
	GetFieldName() string
	GetWriteTime() time.Time
	GetWriter() string

	IsInt() bool
	IsFloat() bool
	IsString() bool
	IsBool() bool
	IsBinaryFile() bool
	IsEntityReference() bool
	IsTimestamp() bool
	IsTransformation() bool

	GetValue() Value
	GetInt() int64
	GetFloat() float64
	GetString() string
	GetBool() bool
	GetBinaryFile() string
	GetEntityReference() string
	GetTimestamp() time.Time
	GetTransformation() string

	SetValue(Value) FieldBinding

	WriteValue(context.Context, Value) FieldBinding
	WriteInt(context.Context, ...interface{}) FieldBinding
	WriteFloat(context.Context, ...interface{}) FieldBinding
	WriteString(context.Context, ...interface{}) FieldBinding
	WriteBool(context.Context, ...interface{}) FieldBinding
	WriteBinaryFile(context.Context, ...interface{}) FieldBinding
	WriteEntityReference(context.Context, ...interface{}) FieldBinding
	WriteTimestamp(context.Context, ...interface{}) FieldBinding
	WriteTransformation(context.Context, ...interface{}) FieldBinding

	ReadValue(context.Context) Value
	ReadInt(context.Context) int64
	ReadFloat(context.Context) float64
	ReadString(context.Context) string
	ReadBool(context.Context) bool
	ReadBinaryFile(context.Context) string
	ReadEntityReference(context.Context) string
	ReadTimestamp(context.Context) time.Time
	ReadTransformation(context.Context) string
}

type FieldQuery

type FieldQuery interface {
	Equals(value any) Query
	NotEquals(value any) Query
	GreaterThan(value any) Query
	LessThan(value any) Query
	LessThanOrEqual(value any) Query
	GreaterThanOrEqual(value any) Query
	Contains(value any) Query
	NotContains(value any) Query
}

type FieldSchema

type FieldSchema interface {
	GetFieldName() string
	GetFieldType() string
}

type MultiBinding added in v0.0.9

type MultiBinding interface {
	Store

	GetEntityById(context.Context, string) EntityBinding
	Commit(context.Context)
}

type Notification

type Notification interface {
	GetToken() string
	GetCurrent() Field
	GetPrevious() Field
	GetContext(index int) Field
	GetContextCount() int
}

type NotificationCallback

type NotificationCallback interface {
	Fn(context.Context, Notification)
	Id() string
}

type NotificationConfig

type NotificationConfig interface {
	GetEntityId() string
	GetEntityType() string
	GetFieldName() string
	GetContextFields() []string
	GetNotifyOnChange() bool
	GetServiceId() string

	SetEntityId(string) NotificationConfig
	SetEntityType(string) NotificationConfig
	SetFieldName(string) NotificationConfig
	SetContextFields(...string) NotificationConfig
	SetNotifyOnChange(bool) NotificationConfig
	SetServiceId(string) NotificationConfig
}

type NotificationToken

type NotificationToken interface {
	Id() string
	Unbind(context.Context)
}

type Query

type Query interface {
	ForType(string) Query
	Where(string) FieldQuery
	Execute(context.Context) []EntityBinding
}

type Request

type Request interface {
	GetEntityId() string
	GetFieldName() string
	GetWriteTime() *time.Time
	GetWriter() *string
	GetValue() Value
	IsSuccessful() bool

	SetEntityId(string) Request
	SetFieldName(string) Request
	SetWriteTime(*time.Time) Request
	SetWriter(*string) Request
	SetValue(Value) Request
	SetSuccessful(bool) Request

	GetWriteOpt() WriteOpt
	SetWriteOpt(WriteOpt) Request
}

type Snapshot

type Snapshot interface {
	GetEntities() []Entity
	GetFields() []Field
	GetSchemas() []EntitySchema

	SetEntities([]Entity)
	SetFields([]Field)
	SetSchemas([]EntitySchema)

	AppendEntity(Entity)
	AppendField(Field)
	AppendSchema(EntitySchema)
}

type SortedSetMember

type SortedSetMember struct {
	Score  float64
	Member string
}

type Store

type Store interface {
	Connect(context.Context)
	Disconnect(context.Context)
	IsConnected(context.Context) bool

	CreateSnapshot(context.Context) Snapshot
	RestoreSnapshot(context.Context, Snapshot)

	CreateEntity(ctx context.Context, entityType, parentId, name string)
	GetEntity(ctx context.Context, entityId string) Entity
	SetEntity(ctx context.Context, value Entity)
	DeleteEntity(ctx context.Context, entityId string)

	FindEntities(ctx context.Context, entityType string) []string
	GetEntityTypes(ctx context.Context) []string

	EntityExists(ctx context.Context, entityId string) bool
	FieldExists(ctx context.Context, fieldName, entityType string) bool

	GetEntitySchema(ctx context.Context, entityType string) EntitySchema
	SetEntitySchema(context.Context, EntitySchema)

	Read(context.Context, ...Request)
	Write(context.Context, ...Request)

	Notify(ctx context.Context, config NotificationConfig, callback NotificationCallback) NotificationToken
	Unnotify(ctx context.Context, subscriptionId string)
	UnnotifyCallback(ctx context.Context, subscriptionId string, callback NotificationCallback)
	ProcessNotifications(context.Context)

	TempSet(ctx context.Context, key string, value string, expiration time.Duration) bool
	TempGet(ctx context.Context, key string) string
	TempExpire(ctx context.Context, key string, expiration time.Duration)
	TempDel(ctx context.Context, key string)

	SortedSetAdd(ctx context.Context, key string, member string, score float64) int64
	SortedSetRemove(ctx context.Context, key string, member string) int64
	SortedSetRemoveRangeByRank(ctx context.Context, key string, start, stop int64) int64
	SortedSetRangeByScoreWithScores(ctx context.Context, key string, min, max string) []SortedSetMember
}

type Transformer

type Transformer interface {
	Transform(context.Context, string, Request)
	ProcessPending()
}

Transformer calls scripts to transform field values of type Transformation

type Value

type Value interface {
	IsNil() bool
	IsInt() bool
	IsFloat() bool
	IsString() bool
	IsBool() bool
	IsBinaryFile() bool
	IsEntityReference() bool
	IsTimestamp() bool
	IsTransformation() bool

	GetType() string
	GetInt() int64
	GetFloat() float64
	GetString() string
	GetBool() bool
	GetBinaryFile() string
	GetEntityReference() string
	GetTimestamp() time.Time
	GetTransformation() string

	SetInt(interface{}) Value
	SetFloat(interface{}) Value
	SetString(interface{}) Value
	SetBool(interface{}) Value
	SetBinaryFile(interface{}) Value
	SetEntityReference(interface{}) Value
	SetTimestamp(interface{}) Value
	SetTransformation(interface{}) Value
}

type WriteOpt

type WriteOpt int
const (
	WriteNormal WriteOpt = iota
	WriteChanges
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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