Documentation
¶
Overview ¶
Package schema provides event schema parsing and code generation.
It reads YAML schema definitions and generates:
- SQL DDL for PostgreSQL tables
- Go models with validation tags
- Storage layer code using pgx COPY protocol
The schema-first approach ensures consistency between database, application code, and validation rules.
Index ¶
- func GenerateConsumer(schema *Schema) (string, error)
- func GenerateGo(schema *Schema) (string, error)
- func GenerateSDK(schema *Schema, language SDKLanguage, apiURL string) (map[string]string, error)
- func GenerateSQL(schema *Schema) (string, error)
- func GenerateStorage(schema *Schema) (string, error)
- type Event
- type Field
- type SDKLanguage
- type Schema
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateConsumer ¶
GenerateConsumer generates consumer event routing and batch handling code
func GenerateGo ¶
GenerateGo generates Go structs for all events in the schema
func GenerateSDK ¶
GenerateSDK generates SDK code for the specified language
func GenerateSQL ¶
GenerateSQL generates PostgreSQL DDL for all events in the schema
func GenerateStorage ¶
GenerateStorage generates PostgreSQL storage writer code for all events
Types ¶
type Event ¶
type Event struct {
Description string `yaml:"description"`
Fields map[string]*Field `yaml:"fields"`
}
Event represents a single event type definition
type Field ¶
type Field struct {
Type string `yaml:"type"`
Required bool `yaml:"required"`
Indexed bool `yaml:"indexed"`
Description string `yaml:"description"`
Default string `yaml:"default"`
Values []string `yaml:"values"`
}
Field represents a field in an event
type SDKLanguage ¶
type SDKLanguage string
SDKLanguage represents a target SDK language
const ( SDKLanguagePython SDKLanguage = "python" SDKLanguageTypeScript SDKLanguage = "typescript" SDKLanguageGo SDKLanguage = "go" SDKLanguageJava SDKLanguage = "java" )
type Schema ¶
Schema represents the entire event schema definition
func ParseSchema ¶
ParseSchema parses YAML schema data. The schema is automatically validated during parsing, so callers do not need to call Validate() separately. Returns a validated Schema or an error if parsing or validation fails.
func ParseSchemaFile ¶
ParseSchemaFile reads and parses a YAML schema file. The schema is automatically validated during parsing, so callers do not need to call Validate() separately.
func (*Schema) GetEventNames ¶
GetEventNames returns a sorted list of event names