forma

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 6 Imported by: 0

README

Forma

Why Develop Forma?

Forma is a general-purpose data management system designed to address the limitations of traditional relational databases (RDBMS) when handling highly dynamic and diverse data structures. As modern applications increasingly demand flexibility and scalability, Forma provides an efficient and easily extensible solution that allows developers to store, query, and manage various types of data without the need for frequent database schema modifications.

Forma chooses JSON Schema as the core method for data definition, enabling users to flexibly define and adjust data structures without worrying about the complexity of table structure changes in traditional databases. By storing data in a dual storage structure of "Hot Fields Table + EAV Table", Forma supports complex query and sorting operations while maintaining high performance.

Why Choose Forma?

Forma vs RDBMS
  • Schema Evolution: Modifying table structures (Schema Migration) in traditional RDBMS often involves table locking and downtime risks. Forma uses JSON Schema to define logical structures, utilizing a "Hot Fields Table (Entity Main) + EAV Table" dual storage pattern underneath. Adding or modifying attributes only requires updating metadata without touching the physical table structure, achieving zero-downtime evolution.
  • Complex Structure Support: Traditional RDBMS usually requires multi-table joins to handle nested objects or arrays. Forma's Transformer layer automatically flattens nested JSON for storage while maintaining the ability to query arrays and deep attributes.
Forma vs MongoDB
  • ACID Transaction Guarantee: Built on top of PostgreSQL, Forma naturally inherits strict ACID transaction properties, ensuring strong consistency for core business data and avoiding the shortcomings of some NoSQL databases in strong consistency scenarios.
  • Power of SQL Optimizer: Forma doesn't just store JSON; its built-in SQLGenerator compiles complex JSON filter conditions into efficient SQL queries (utilizing CTEs and Exists subqueries). This fully leverages Postgres's powerful query optimizer and avoids the common N+1 query problem found in EAV models.
Forma vs KV Store
  • Multi-dimensional Retrieval Capabilities: KV Stores excel at retrieving Values by Key but struggle with complex conditional filtering (e.g., age > 20 AND status = 'active'). Forma supports combination filtering, sorting, and pagination on arbitrary attributes, and even cross-schema search.
  • Data Validation & Type Safety: KV Stores typically treat Values as black boxes. Forma strictly follows JSON Schema for data validation (types, formats, required fields), ensuring the quality of incoming data.

Use Cases

OLTP Applications
  • Dynamic Business Systems: Ideal for systems like CRM, ERP, or CMS that require frequent data model adjustments or support for user-defined fields (Custom Fields).
  • Automated RESTful API: Developers only need to define the JSON Schema, and Forma automatically provides standard CRUD interfaces (Create, Read, Update, Delete), significantly shortening the backend development cycle.
  • High-Performance Read/Write: Core high-frequency fields are stored in the "Hot Fields Table", ensuring read/write performance on critical paths is comparable to native SQL tables, while supporting high-concurrency transaction processing.
OLAP Applications
  • Real-time Operational Analysis: Leverages Postgres's query capabilities to support real-time statistics and aggregation analysis of business data.
  • Data Lake Integration: Supports exporting structured data to columnar formats like Parquet and storing it in S3, enabling integration with big data platforms for offline analysis and report generation. Parquet files can be partitioned by schema_id and row_id for efficient updates and queries.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeMetadata added in v0.0.3

type AttributeMetadata struct {
	AttributeName string             `json:"attr_name"`  // attr_name, JSON Path
	AttributeID   int16              `json:"attr_id"`    // attr_id
	ValueType     ValueType          `json:"value_type"` // 'text', 'numeric', 'date', 'bool'
	ColumnBinding *MainColumnBinding `json:"column_binding,omitempty"`
}

AttributeMetadata stores cached metadata from the attributes table.

func (AttributeMetadata) IsInsideArray added in v0.0.3

func (m AttributeMetadata) IsInsideArray() bool

IsInsideArray infers if the attribute is inside an array based on its name.

func (AttributeMetadata) Location added in v0.0.3

Location returns where the attribute is stored. If ColumnBinding is nil, the attribute is in EAV; otherwise in main table.

type AttributeStorageLocation added in v0.0.3

type AttributeStorageLocation string

AttributeStorageLocation enumerates where the attribute physically resides.

const (
	AttributeStorageLocationUnknown AttributeStorageLocation = ""
	AttributeStorageLocationMain    AttributeStorageLocation = "main"
	AttributeStorageLocationEAV     AttributeStorageLocation = "eav"
)

type BatchConfig added in v0.0.2

type BatchConfig struct {
	EnableDynamicSizing      bool `json:"enableDynamicSizing"`
	EnableParallelProcessing bool `json:"enableParallelProcessing"`
	EnableBatchStreaming     bool `json:"enableBatchStreaming"`
	ParallelThreshold        int  `json:"parallelThreshold"`
	StreamingThreshold       int  `json:"streamingThreshold"`
	MaxParallelWorkers       int  `json:"maxParallelWorkers"`
	StreamingChunkSize       int  `json:"streamingChunkSize"`
	StreamingDelay           int  `json:"streamingDelay"` // milliseconds
	MaxComplexityPerBatch    int  `json:"maxComplexityPerBatch"`
	AttributeComplexityScore int  `json:"attributeComplexityScore"`
	OptimalChunkSize         int  `json:"optimalChunkSize"`
}

BatchConfig contains batch processing settings

type BatchOperation

type BatchOperation struct {
	Operations []EntityOperation `json:"operations"`
	Atomic     bool              `json:"atomic"` // Whether to use transactions
}

BatchOperation represents batch entity operations

type BatchResult

type BatchResult struct {
	Successful []*DataRecord    `json:"successful"`
	Failed     []OperationError `json:"failed"`
	TotalCount int              `json:"totalCount"`
	Duration   int64            `json:"duration"` // microseconds
}

BatchResult represents results from batch operations

type CascadeAction added in v0.0.2

type CascadeAction string

CascadeAction defines the type of cascade action

const (
	CascadeActionDelete   CascadeAction = "delete"
	CascadeActionUpdate   CascadeAction = "update"
	CascadeActionNullify  CascadeAction = "nullify"
	CascadeActionRestrict CascadeAction = "restrict"
)

type CascadeRule added in v0.0.2

type CascadeRule struct {
	SourceSchema string        `json:"sourceSchema"`
	TargetSchema string        `json:"targetSchema"`
	Action       CascadeAction `json:"action"`
	MaxDepth     int           `json:"maxDepth,omitempty"`
}

CascadeRule defines cascade behavior for specific schema relationships

type CompositeCondition

type CompositeCondition struct {
	Logic      Logic       `json:"l"`
	Conditions []Condition `json:"c"`
}

--- 3. Composite Condition (Non-Leaf Node) ---

func (*CompositeCondition) IsLeaf

func (c *CompositeCondition) IsLeaf() bool

func (*CompositeCondition) UnmarshalJSON

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

UnmarshalJSON customizes decoding so that nested conditions are turned into the appropriate concrete condition implementations.

type Condition

type Condition interface {
	IsLeaf() bool
}

--- 2. Interface (The Core) ---

type Config added in v0.0.2

type Config struct {
	Database       DatabaseConfig    `json:"database"`
	Query          QueryConfig       `json:"query"`
	Entity         EntityConfig      `json:"entity"`
	Transaction    TransactionConfig `json:"transaction"`
	Performance    PerformanceConfig `json:"performance"`
	Logging        LoggingConfig     `json:"logging"`
	Metrics        MetricsConfig     `json:"metrics"`
	Reference      ReferenceConfig   `json:"reference"`
	SchemaRegistry SchemaRegistry    `json:"-"` // Custom schema registry implementation (optional)
}

Config consolidates settings from both modules

func DefaultConfig added in v0.0.2

func DefaultConfig(schemaRegistry SchemaRegistry) *Config

DefaultConfig returns a default configuration

func (*Config) Validate added in v0.0.2

func (c *Config) Validate() error

Validate validates the configuration

type ConfigError added in v0.0.2

type ConfigError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

ConfigError represents a configuration validation error

func (*ConfigError) Error added in v0.0.2

func (e *ConfigError) Error() string

type CrossSchemaRequest

type CrossSchemaRequest struct {
	SchemaNames  []string  `json:"schema_names" validate:"required"`
	SearchTerm   string    `json:"search_term" validate:"required"`
	Page         int       `json:"page" validate:"min=1"`
	ItemsPerPage int       `json:"items_per_page" validate:"min=1,max=100"`
	Condition    Condition `json:"-"` // Custom unmarshal, can be CompositeCondition or KvCondition
}

CrossSchemaRequest represents a cross-schema search request

func (CrossSchemaRequest) MarshalJSON

func (r CrossSchemaRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for CrossSchemaRequest.

func (*CrossSchemaRequest) UnmarshalJSON

func (r *CrossSchemaRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for CrossSchemaRequest. It allows the Condition field to be either a CompositeCondition or KvCondition.

type CursorQueryResult

type CursorQueryResult struct {
	Data          []*DataRecord `json:"data"`
	NextCursor    string        `json:"next_cursor,omitempty"`
	HasMore       bool          `json:"has_more"`
	ExecutionTime time.Duration `json:"execution_time"`
}

CursorQueryResult represents cursor-based pagination results.

type DataRecord

type DataRecord struct {
	SchemaName string         `json:"schema_name"`
	RowID      uuid.UUID      `json:"row_id"`
	Attributes map[string]any `json:"attributes"`
}

type DatabaseConfig added in v0.0.2

type DatabaseConfig struct {
	Host            string        `json:"host"`
	Port            int           `json:"port"`
	Database        string        `json:"database"`
	Username        string        `json:"username"`
	Password        string        `json:"password"`
	SSLMode         string        `json:"sslMode"`
	MaxConnections  int           `json:"maxConnections"`
	MaxIdleConns    int           `json:"maxIdleConns"`
	ConnMaxLifetime time.Duration `json:"connMaxLifetime"`
	ConnMaxIdleTime time.Duration `json:"connMaxIdleTime"`
	Timeout         time.Duration `json:"timeout"`
	TableNames      TableNames    `json:"tableNames"`
}

DatabaseConfig contains database connection settings

type EntityConfig added in v0.0.2

type EntityConfig struct {
	EnableReferenceValidation bool          `json:"enableReferenceValidation"`
	EnableCascadeDelete       bool          `json:"enableCascadeDelete"`
	BatchSize                 int           `json:"batchSize"`
	CacheEnabled              bool          `json:"cacheEnabled"`
	CacheTTL                  time.Duration `json:"cacheTTL"`
	MaxEntitySize             int           `json:"maxEntitySize"`
	EnableVersioning          bool          `json:"enableVersioning"`
	SchemaDirectory           string        `json:"schemaDirectory"`
}

EntityConfig contains entity management settings

type EntityIdentifier

type EntityIdentifier struct {
	SchemaName string    `json:"schemaName"`
	RowID      uuid.UUID `json:"rowId"`
}

EntityIdentifier identifies an entity for operations

type EntityManager

type EntityManager interface {
	// Entity CRUD operations
	Create(ctx context.Context, req *EntityOperation) (*DataRecord, error)
	Get(ctx context.Context, req *QueryRequest) (*DataRecord, error)
	Update(ctx context.Context, req *EntityOperation) (*DataRecord, error)
	Delete(ctx context.Context, req *EntityOperation) error

	// Query operations
	Query(ctx context.Context, req *QueryRequest) (*QueryResult, error)
	CrossSchemaSearch(ctx context.Context, req *CrossSchemaRequest) (*QueryResult, error)

	// Batch operations
	BatchCreate(ctx context.Context, req *BatchOperation) (*BatchResult, error)
	BatchUpdate(ctx context.Context, req *BatchOperation) (*BatchResult, error)
	BatchDelete(ctx context.Context, req *BatchOperation) (*BatchResult, error)
}

EntityManager provides comprehensive entity and query operations

type EntityOperation

type EntityOperation struct {
	EntityIdentifier
	Type    OperationType  `json:"type"`
	Data    map[string]any `json:"data,omitempty"`
	Updates map[string]any `json:"updates,omitempty"`
}

EntityOperation represents CRUD operations

type EntityUpdate

type EntityUpdate struct {
	EntityIdentifier
	Updates any `json:"updates"`
}

EntityUpdate represents an update operation

type FilterField

type FilterField string
const (
	FilterFieldAttributeName FilterField = "attr_name"
	FilterFieldValueText     FilterField = "value_text"
	FilterFieldValueNumeric  FilterField = "value_numeric"
	FilterFieldRowID         FilterField = "row_id"
	FilterFieldSchemaName    FilterField = "schema_name"
)

type FilterType

type FilterType string

FilterType defines supported filter operations

const (
	FilterEquals      FilterType = "equals"
	FilterNotEquals   FilterType = "not_equals"
	FilterStartsWith  FilterType = "starts_with"
	FilterContains    FilterType = "contains"
	FilterGreaterThan FilterType = "gt"
	FilterLessThan    FilterType = "lt"
	FilterGreaterEq   FilterType = "gte"
	FilterLessEq      FilterType = "lte"
	FilterIn          FilterType = "in"
	FilterNotIn       FilterType = "not_in"
)

type KvCondition

type KvCondition struct {
	Attr  string `json:"a"`
	Value string `json:"v"`
}

--- 4. KvCondition (Leaf Node) ---

func (*KvCondition) IsLeaf

func (kv *KvCondition) IsLeaf() bool

func (*KvCondition) UnmarshalJSON

func (kv *KvCondition) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures short-hand keys are present.

type LoggingConfig added in v0.0.2

type LoggingConfig struct {
	Level                  string        `json:"level"`
	Format                 string        `json:"format"`
	EnableStructured       bool          `json:"enableStructured"`
	EnablePerformance      bool          `json:"enablePerformance"`
	EnableQueryLogging     bool          `json:"enableQueryLogging"`
	LogSlowQueries         bool          `json:"logSlowQueries"`
	SlowQueryThreshold     time.Duration `json:"slowQueryThreshold"`
	MaxLogSize             int           `json:"maxLogSize"`
	LogRotation            bool          `json:"logRotation"`
	SanitizeParameters     bool          `json:"sanitizeParameters"`
	LogQueries             bool          `json:"logQueries"`
	LogErrors              bool          `json:"logErrors"`
	LogSecurityEvents      bool          `json:"logSecurityEvents"`
	LogPerformanceWarnings bool          `json:"logPerformanceWarnings"`
	LogAllOperations       bool          `json:"logAllOperations"`
	EnableDetailedLogging  bool          `json:"enableDetailedLogging"`
}

LoggingConfig contains logging settings

type Logic

type Logic string
const (
	LogicAnd Logic = "and"
	LogicOr  Logic = "or"
)

type MainColumn added in v0.0.3

type MainColumn string

MainColumn represents column names in the main entity table.

const (
	MainColumnText01     MainColumn = "text_01"
	MainColumnText02     MainColumn = "text_02"
	MainColumnText03     MainColumn = "text_03"
	MainColumnText04     MainColumn = "text_04"
	MainColumnText05     MainColumn = "text_05"
	MainColumnText06     MainColumn = "text_06"
	MainColumnText07     MainColumn = "text_07"
	MainColumnText08     MainColumn = "text_08"
	MainColumnText09     MainColumn = "text_09"
	MainColumnText10     MainColumn = "text_10"
	MainColumnSmallint01 MainColumn = "smallint_01"
	MainColumnSmallint02 MainColumn = "smallint_02"
	MainColumnInteger01  MainColumn = "integer_01"
	MainColumnInteger02  MainColumn = "integer_02"
	MainColumnInteger03  MainColumn = "integer_03"
	MainColumnBigint01   MainColumn = "bigint_01"
	MainColumnBigint02   MainColumn = "bigint_02"
	MainColumnBigint03   MainColumn = "bigint_03"
	MainColumnBigint04   MainColumn = "bigint_04"
	MainColumnBigint05   MainColumn = "bigint_05"
	MainColumnDouble01   MainColumn = "double_01"
	MainColumnDouble02   MainColumn = "double_02"
	MainColumnDouble03   MainColumn = "double_03"
	MainColumnDouble04   MainColumn = "double_04"
	MainColumnDouble05   MainColumn = "double_05"
	MainColumnUUID01     MainColumn = "uuid_01"
	MainColumnUUID02     MainColumn = "uuid_02"
	MainColumnCreatedAt  MainColumn = "ltbase_created_at"
	MainColumnUpdatedAt  MainColumn = "ltbase_updated_at"
	MainColumnDeletedAt  MainColumn = "ltbase_deleted_at"
	MainColumnSchemaID   MainColumn = "ltbase_schema_id"
	MainColumnRowID      MainColumn = "ltbase_row_id"
)

type MainColumnBinding added in v0.0.3

type MainColumnBinding struct {
	ColumnName MainColumn         `json:"col_name"`
	Encoding   MainColumnEncoding `json:"encoding,omitempty"`
}

MainColumnBinding describes how a schema attribute maps into a hot attribute column.

func (*MainColumnBinding) ColumnType added in v0.0.3

func (m *MainColumnBinding) ColumnType() MainColumnType

ColumnType derives the column type from the column name prefix.

type MainColumnEncoding added in v0.0.3

type MainColumnEncoding string

MainColumnEncoding represents special encoding for main column values.

const (
	MainColumnEncodingDefault  MainColumnEncoding = "default"
	MainColumnEncodingBoolText MainColumnEncoding = "bool_text" // "true"/"false" string
	MainColumnEncodingUnixMs   MainColumnEncoding = "unix_ms"
	MainColumnEncodingBoolInt  MainColumnEncoding = "bool_smallint"
	MainColumnEncodingISO8601  MainColumnEncoding = "iso8601"
)

type MainColumnType added in v0.0.3

type MainColumnType string

MainColumnType represents the data type of a main column.

const (
	MainColumnTypeText     MainColumnType = "text"
	MainColumnTypeSmallint MainColumnType = "smallint"
	MainColumnTypeInteger  MainColumnType = "integer"
	MainColumnTypeBigint   MainColumnType = "bigint"
	MainColumnTypeDouble   MainColumnType = "double"
	MainColumnTypeUUID     MainColumnType = "uuid"
)

type MetricsConfig added in v0.0.2

type MetricsConfig struct {
	Enabled                  bool              `json:"enabled"`
	Provider                 string            `json:"provider"` // prometheus, statsd, etc.
	Endpoint                 string            `json:"endpoint"`
	CollectionInterval       time.Duration     `json:"collectionInterval"`
	EnableHistograms         bool              `json:"enableHistograms"`
	EnableCounters           bool              `json:"enableCounters"`
	EnableGauges             bool              `json:"enableGauges"`
	Namespace                string            `json:"namespace"`
	Labels                   map[string]string `json:"labels"`
	MaxSamples               int               `json:"maxSamples"`
	EnableOperationMetrics   bool              `json:"enableOperationMetrics"`
	EnableTransactionMetrics bool              `json:"enableTransactionMetrics"`
	EnablePatternMetrics     bool              `json:"enablePatternMetrics"`
}

MetricsConfig contains metrics collection settings

type OperationError

type OperationError struct {
	Operation EntityOperation `json:"operation"`
	Error     string          `json:"error"`
	Code      string          `json:"code"`
	Details   map[string]any  `json:"details,omitempty"`
}

OperationError represents an error for a specific operation

type OperationType

type OperationType string

OperationType represents CRUD operations

const (
	OperationCreate OperationType = "create"
	OperationRead   OperationType = "read"
	OperationUpdate OperationType = "update"
	OperationDelete OperationType = "delete"
	OperationQuery  OperationType = "query"
)

type OrderBy

type OrderBy struct {
	Attribute string    `json:"attribute"`
	SortOrder SortOrder `json:"sort_order,omitempty"`
}

type PerformanceConfig added in v0.0.2

type PerformanceConfig struct {
	EnableMonitoring          bool          `json:"enableMonitoring"`
	SlowQueryThreshold        time.Duration `json:"slowQueryThreshold"`
	SlowOperationThreshold    time.Duration `json:"slowOperationThreshold"`
	MetricsCollectionInterval time.Duration `json:"metricsCollectionInterval"`
	BatchSize                 int           `json:"batchSize"`
	MaxBatchSize              int           `json:"maxBatchSize"`
	Batch                     BatchConfig   `json:"batch"`

	// Unified monitoring settings
	MaxMetricsHistory      int           `json:"maxMetricsHistory"`
	MaxAlertsHistory       int           `json:"maxAlertsHistory"`
	MaxRecommendations     int           `json:"maxRecommendations"`
	EnableAlerting         bool          `json:"enableAlerting"`
	EnableRecommendations  bool          `json:"enableRecommendations"`
	AlertingInterval       time.Duration `json:"alertingInterval"`
	RecommendationInterval time.Duration `json:"recommendationInterval"`

	// Memory monitoring
	EnableMemoryMonitoring bool  `json:"enableMemoryMonitoring"`
	MemoryThreshold        int64 `json:"memoryThreshold"`

	// Correlation tracking
	EnableCorrelationTracking bool          `json:"enableCorrelationTracking"`
	CorrelationTTL            time.Duration `json:"correlationTTL"`
}

PerformanceConfig contains performance monitoring settings

type QueryConfig added in v0.0.2

type QueryConfig struct {
	DefaultTimeout     time.Duration `json:"defaultTimeout"`
	MaxRows            int           `json:"maxRows"`
	DefaultPageSize    int           `json:"defaultPageSize"`
	MaxPageSize        int           `json:"maxPageSize"`
	EnableQueryPlan    bool          `json:"enableQueryPlan"`
	EnableOptimization bool          `json:"enableOptimization"`
	CacheQueryPlans    bool          `json:"cacheQueryPlans"`
	QueryPlanCacheTTL  time.Duration `json:"queryPlanCacheTTL"`
}

QueryConfig contains query execution settings

type QueryRequest

type QueryRequest struct {
	SchemaName   string     `json:"schema_name" validate:"required"`
	Page         int        `json:"page" validate:"min=1"`
	ItemsPerPage int        `json:"items_per_page" validate:"min=1,max=100"`
	Condition    Condition  `json:"-"` // Custom unmarshal, can be CompositeCondition or KvCondition
	SortBy       []string   `json:"sort_by,omitempty"`
	SortOrder    SortOrder  `json:"sort_order,omitempty"`
	RowID        *uuid.UUID `json:"row_id,omitempty"` // For entity-specific operations
}

QueryRequest represents a pagination query request.

func (QueryRequest) MarshalJSON

func (r QueryRequest) MarshalJSON() ([]byte, error)

MarshalJSON implements custom JSON marshaling for QueryRequest.

func (*QueryRequest) UnmarshalJSON

func (r *QueryRequest) UnmarshalJSON(data []byte) error

UnmarshalJSON implements custom JSON unmarshaling for QueryRequest. It allows the Condition field to be either a CompositeCondition or KvCondition.

type QueryResult

type QueryResult struct {
	Data          []*DataRecord `json:"data"`
	TotalRecords  int           `json:"total_records"`
	TotalPages    int           `json:"total_pages"`
	CurrentPage   int           `json:"current_page"`
	ItemsPerPage  int           `json:"items_per_page"`
	HasNext       bool          `json:"has_next"`
	HasPrevious   bool          `json:"has_previous"`
	ExecutionTime time.Duration `json:"execution_time"`
}

QueryResult represents paginated query results.

type Reference

type Reference struct {
	SourceSchemaName string        `json:"sourceSchemaName"`
	SourceRowID      uuid.UUID     `json:"sourceRowId"`
	SourceFieldName  string        `json:"sourceFieldName"`
	TargetSchemaName string        `json:"targetSchemaName"`
	TargetRowID      uuid.UUID     `json:"targetRowId"`
	ReferenceType    ReferenceType `json:"referenceType"`
}

Reference represents a reference from one entity to another

type ReferenceConfig added in v0.0.2

type ReferenceConfig struct {
	ValidateOnCreate bool                   `json:"validateOnCreate"`
	ValidateOnUpdate bool                   `json:"validateOnUpdate"`
	CheckIntegrity   bool                   `json:"checkIntegrity"`
	CascadeDelete    bool                   `json:"cascadeDelete"`
	CascadeUpdate    bool                   `json:"cascadeUpdate"`
	MaxCascadeDepth  int                    `json:"maxCascadeDepth"`
	CascadeRules     map[string]CascadeRule `json:"cascadeRules,omitempty"`
	EnableCaching    bool                   `json:"enableCaching"`
	CacheTTL         time.Duration          `json:"cacheTTL"`
	MaxCacheSize     int                    `json:"maxCacheSize"`
	BatchSize        int                    `json:"batchSize"`
}

ReferenceConfig contains reference management settings

type ReferenceType

type ReferenceType string

ReferenceType represents the type of reference

const (
	ReferenceTypeSingle ReferenceType = "single"
	ReferenceTypeArray  ReferenceType = "array"
	ReferenceTypeNested ReferenceType = "nested"
)

type SchemaAttributeCache added in v0.0.3

type SchemaAttributeCache map[string]AttributeMetadata

SchemaAttributeCache is a mapping of attr_name -> metadata. Strongly recommended to populate per schema_id at application startup.

type SchemaRegistry added in v0.0.3

type SchemaRegistry interface {
	// GetSchemaByName retrieves schema ID and attribute cache by schema name
	GetSchemaByName(name string) (int16, SchemaAttributeCache, error)
	// GetSchemaByID retrieves schema name and attribute cache by schema ID
	GetSchemaByID(id int16) (string, SchemaAttributeCache, error)
	// ListSchemas returns a list of all registered schema names
	ListSchemas() []string
}

SchemaRegistry provides schema lookup operations. Implementations can load schemas from files, databases, or other sources.

type SortOrder

type SortOrder string

SortOrder defines sort direction

const (
	SortOrderAsc  SortOrder = "asc"
	SortOrderDesc SortOrder = "desc"
)

type TableNames added in v0.0.2

type TableNames struct {
	SchemaRegistry string `json:"schemaRegistry"`
	EntityMain     string `json:"entityMain"`
	EAVData        string `json:"eavData"`
}

TableNames generates the table names for a specific client and project

type TransactionConfig added in v0.0.2

type TransactionConfig struct {
	DefaultTimeout           time.Duration `json:"defaultTimeout"`
	MaxTimeout               time.Duration `json:"maxTimeout"`
	MaxRetryAttempts         int           `json:"maxRetryAttempts"`
	RetryAttempts            int           `json:"retryAttempts"`
	RetryDelay               time.Duration `json:"retryDelay"`
	IsolationLevel           string        `json:"isolationLevel"`
	EnableDeadlockDetection  bool          `json:"enableDeadlockDetection"`
	DeadlockCheckInterval    time.Duration `json:"deadlockCheckInterval"`
	DeadlockMaxWaitTime      time.Duration `json:"deadlockMaxWaitTime"`
	SlowTransactionThreshold time.Duration `json:"slowTransactionThreshold"`
	MinSuccessRate           float64       `json:"minSuccessRate"`
	MaxAverageDuration       time.Duration `json:"maxAverageDuration"`
	MaxConnectionPoolUsage   float64       `json:"maxConnectionPoolUsage"`
}

TransactionConfig contains transaction settings

type ValueType added in v0.0.3

type ValueType string

ValueType represents supported attribute value types.

const (
	ValueTypeText     ValueType = "text"
	ValueTypeSmallInt ValueType = "smallint"
	ValueTypeInteger  ValueType = "integer"
	ValueTypeBigInt   ValueType = "bigint"
	ValueTypeNumeric  ValueType = "numeric"  // double precision
	ValueTypeDate     ValueType = "date"     // for JSON attributes with format `date`
	ValueTypeDateTime ValueType = "datetime" // for JSON attributes with format `date-time`
	ValueTypeUUID     ValueType = "uuid"
	ValueTypeBool     ValueType = "bool"
)

Directories

Path Synopsis
cmd
sample command
server command
tools command

Jump to

Keyboard shortcuts

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