Documentation
¶
Index ¶
- Constants
- Variables
- type AggregateCommandGenerator
- type AggregateCreateCommandGenerator
- type ApplicationContext
- func (a *ApplicationContext) AppendEventStore(aggregate libdomain.Aggregate)
- func (a *ApplicationContext) Authenticate(authService AuthService) error
- func (a *ApplicationContext) CacheManager() *CacheManager
- func (a *ApplicationContext) CleanCache()
- func (a *ApplicationContext) Commit(err error) error
- func (a *ApplicationContext) Copy() *ApplicationContext
- func (a *ApplicationContext) DomainEventPublisherInstance() *libdomain.DomainEventPublisherInstance
- func (a *ApplicationContext) EventCollector() *EventCollector
- func (a *ApplicationContext) FromDomain() bool
- func (a *ApplicationContext) GetDeterministicTestIds(entityName string) int
- func (a *ApplicationContext) GetTimestamp() int64
- func (a *ApplicationContext) IsSudo() bool
- func (a *ApplicationContext) PublishPendingEvents() error
- func (a *ApplicationContext) SetDeterministicTestIds(entityName string, value int)
- func (a *ApplicationContext) Sudo() libdomain.ApplicationContext
- func (a *ApplicationContext) TransactionManager() *TransactionManager
- func (a *ApplicationContext) WithContext(ctx context.Context) *ApplicationContext
- func (a *ApplicationContext) WithSudo() *ApplicationContext
- func (a *ApplicationContext) WithTenantID(tenantID libdomain.TenantID) *ApplicationContext
- func (a *ApplicationContext) Workflow() *libdomain.Workflow
- type ApplicationService
- type AuthService
- type CacheClient
- type CacheManager
- func (c *CacheManager) CleanCache()
- func (c *CacheManager) Client() CacheClient
- func (c *CacheManager) Commit(ctx context.Context)
- func (c *CacheManager) Get(model, key string) (*WorkflowCache, bool)
- func (c *CacheManager) GetCache() map[string]map[string]*WorkflowCache
- func (c *CacheManager) Invalidate(model, key string)
- func (c *CacheManager) Set(model, key string, cache *WorkflowCache)
- type DataTransferObjectDefinition
- func (t *DataTransferObjectDefinition) AggregateDefinition() *libdomain.AggregateDefinition
- func (t *DataTransferObjectDefinition) BoundedContext() *libdomain.BoundedContext
- func (t *DataTransferObjectDefinition) DomainPackage() string
- func (t *DataTransferObjectDefinition) DomainPath() string
- func (t *DataTransferObjectDefinition) FactoryTitle() string
- func (t *DataTransferObjectDefinition) GetAbstract() bool
- func (t *DataTransferObjectDefinition) GetCommands() *libdomain.EntityCommandsDefinition
- func (t *DataTransferObjectDefinition) GetDisableDatabaseStore() bool
- func (t *DataTransferObjectDefinition) GetDisableID() bool
- func (t *DataTransferObjectDefinition) GetDisableMetadata() bool
- func (t *DataTransferObjectDefinition) GetKeys() []libdomain.Property
- func (t *DataTransferObjectDefinition) GetName() string
- func (t *DataTransferObjectDefinition) GetNoCache() bool
- func (t *DataTransferObjectDefinition) GetProperties() []libdomain.Property
- func (t *DataTransferObjectDefinition) GetType() string
- func (t *DataTransferObjectDefinition) GetUseOneOf() bool
- func (t *DataTransferObjectDefinition) HasDeletionGuard() bool
- func (f *DataTransferObjectDefinition) HasNameProperty() bool
- func (t *DataTransferObjectDefinition) HasTranslatable() bool
- func (t *DataTransferObjectDefinition) IdentityDomainPackage() string
- func (t *DataTransferObjectDefinition) IdentityTitle() string
- func (t *DataTransferObjectDefinition) ImportKeyNames() []string
- func (t *DataTransferObjectDefinition) IsAggregateRoot() bool
- func (t *DataTransferObjectDefinition) IsEntity() bool
- func (t *DataTransferObjectDefinition) NaturalKeyName() string
- func (t *DataTransferObjectDefinition) NaturalKeyNames() []string
- func (t *DataTransferObjectDefinition) NaturalKeyTitle() string
- func (t *DataTransferObjectDefinition) NestedProperties() []libdomain.Property
- func (f *DataTransferObjectDefinition) Prefix() string
- func (t *DataTransferObjectDefinition) ScopeKeyNames() []string
- func (t *DataTransferObjectDefinition) Snake() string
- func (t *DataTransferObjectDefinition) StoredProperties() []libdomain.Property
- func (t *DataTransferObjectDefinition) Subdomain() *libdomain.SubdomainDefinition
- func (t *DataTransferObjectDefinition) Title() string
- func (f *DataTransferObjectDefinition) Upper() string
- func (t *DataTransferObjectDefinition) UseTenants() bool
- type Definitions
- type EntityInterface
- type Event
- type EventCollector
- func (e *EventCollector) AppendEventStore(aggregate libdomain.Aggregate)
- func (e *EventCollector) Clear()
- func (e *EventCollector) EventCount() int
- func (e *EventCollector) GetEvents() []*Event
- func (e *EventCollector) GetEventsByStream() (map[string][]*Event, []*Event)
- func (e *EventCollector) HasEvents() bool
- type EventData
- type ImportErrorInterface
- type ImportSuccessInterface
- type NestedCommandGenerator
- type NestedEntityLevel
- type OnDeleteValue
- type ProtobufInterface
- type RepeatedProperty
- func (r *RepeatedProperty) DBType() *libdomain.DBType
- func (r *RepeatedProperty) GetInverseProperty() string
- func (r *RepeatedProperty) GetLoadedPosition() int
- func (r *RepeatedProperty) GetLoadedPositionEntity() int
- func (r *RepeatedProperty) GetName() string
- func (r *RepeatedProperty) GetPosition() int
- func (r *RepeatedProperty) GetPositionEntity() int
- func (r *RepeatedProperty) GetPrimaryKey() bool
- func (r *RepeatedProperty) GetReferenceName() string
- func (r *RepeatedProperty) GetRequired() bool
- func (r *RepeatedProperty) GetReturnDetailsInTests() bool
- func (r *RepeatedProperty) GoNil() string
- func (r *RepeatedProperty) GoType() string
- func (r *RepeatedProperty) GoTypeID() string
- func (r *RepeatedProperty) GraphqlSchemaType() string
- func (r *RepeatedProperty) GraphqlType() string
- func (r *RepeatedProperty) IsNested() bool
- func (r *RepeatedProperty) IsRepeated() bool
- func (r *RepeatedProperty) IsStored() bool
- func (r *RepeatedProperty) IsTranslatable() bool
- func (r *RepeatedProperty) JSONType() string
- func (r *RepeatedProperty) LoadedPosition() int
- func (r *RepeatedProperty) LoadedPositionEntity() int
- func (r *RepeatedProperty) NameWithoutID() string
- func (r *RepeatedProperty) Position() int
- func (r *RepeatedProperty) PositionEntity() int
- func (r *RepeatedProperty) ProtoTypeArg() string
- func (r *RepeatedProperty) SetPosition(position int)
- func (r *RepeatedProperty) Snake() string
- func (r *RepeatedProperty) Title() string
- func (r *RepeatedProperty) TitleWithoutID() string
- func (r *RepeatedProperty) Type() libdomain.PropertyType
- func (r *RepeatedProperty) Upper() string
- type RequestDefinition
- func (f *RequestDefinition) FromDomain() bool
- func (f *RequestDefinition) GetArgs() []libdomain.Argument
- func (f *RequestDefinition) GetName() string
- func (f *RequestDefinition) GetResults() []libdomain.Argument
- func (f *RequestDefinition) GetService() *ServiceDefinition
- func (f *RequestDefinition) IsBatchable() bool
- func (f *RequestDefinition) IsCommand() bool
- func (f *RequestDefinition) SetFromDomain(fromDomain bool)
- func (f *RequestDefinition) Title() string
- func (f *RequestDefinition) UseTenants() bool
- type ServiceDefinition
- func (a *ServiceDefinition) ApplicationPackage() string
- func (a *ServiceDefinition) ApplicationPath() string
- func (a *ServiceDefinition) GetCustomRequests() []*RequestDefinition
- func (a *ServiceDefinition) Snake() string
- func (a *ServiceDefinition) Title() string
- func (a *ServiceDefinition) TitleWithPackage() string
- type StructuredImportError
- type TableInterface
- type TransactionClient
- type TransactionManager
- func (t *TransactionManager) Begin(ctx *ApplicationContext, readWrite bool) error
- func (t *TransactionManager) Client() TransactionClient
- func (t *TransactionManager) Commit(ctx *ApplicationContext, events []*Event) error
- func (t *TransactionManager) GetTransaction() interface{}
- func (t *TransactionManager) Rollback(ctx *ApplicationContext) error
- func (t *TransactionManager) SetTransaction(transaction interface{})
- type WorkflowCache
Constants ¶
const OnDeleteCascade = OnDeleteValue("CASCADE")
const OnDeleteProtect = OnDeleteValue("PROTECT")
const OnDeleteSetNull = OnDeleteValue("SET NULL")
const RepeatedPropertyType = libdomain.PropertyType("RepeatedPropertyType")
const STRING = "string"
STRING is a contains reprensenting the widely used string type.
Variables ¶
var SetAggregateIDProperty func(string) libdomain.PropertyDefinition
Functions ¶
This section is empty.
Types ¶
type AggregateCommandGenerator ¶
type AggregateCommandGenerator struct {
Method *libdomain.RequestDefinition
AggregateID string
}
func (*AggregateCommandGenerator) Generate ¶
func (c *AggregateCommandGenerator) Generate() string
func (*AggregateCommandGenerator) Imports ¶
func (c *AggregateCommandGenerator) Imports() []*libdomain.PackageLocation
func (*AggregateCommandGenerator) Type ¶
func (c *AggregateCommandGenerator) Type() string
type AggregateCreateCommandGenerator ¶
type AggregateCreateCommandGenerator struct {
Aggregate *libdomain.AggregateDefinition
NewPackage *libdomain.PackageLocation
NewFunction string
Args []string
}
func (*AggregateCreateCommandGenerator) Generate ¶
func (c *AggregateCreateCommandGenerator) Generate() string
func (*AggregateCreateCommandGenerator) Imports ¶
func (c *AggregateCreateCommandGenerator) Imports() []*libdomain.PackageLocation
func (*AggregateCreateCommandGenerator) Type ¶
func (c *AggregateCreateCommandGenerator) Type() string
type ApplicationContext ¶
type ApplicationContext struct {
// contains filtered or unexported fields
}
ApplicationContextRefactored is the refactored version of ApplicationContext that uses focused component managers instead of handling all concerns directly.
This version follows the Single Responsibility Principle by delegating: - Event management to EventCollector - Cache management to CacheManager - Transaction management to TransactionManager
Migration guide: 1. Replace NewApplicationContext with NewApplicationContextRefactored 2. Use ctx.EventCollector() instead of directly accessing eventsForEventStore 3. Use ctx.CacheManager() instead of directly accessing cache 4. Use ctx.TransactionManager() instead of TransactionClient
func NewApplicationContext ¶
func NewApplicationContext( ctx context.Context, transactionClient TransactionClient, cacheClient CacheClient, domainEventPublisher *libdomain.DomainEventPublisher, fromDomain bool, ) *ApplicationContext
NewApplicationContextRefactored creates a new refactored ApplicationContext.
Parameters:
- ctx: The Go context for the workflow
- transactionClient: Client for database transactions
- cacheClient: Client for caching (e.g., Redis)
- domainEventPublisher: Publisher for domain events
- fromDomain: True if called from domain layer
Returns:
- A new ApplicationContext with focused component managers
func NewApplicationContextFromService ¶
func NewApplicationContextFromService( c context.Context, tenantID string, locale string, s ApplicationService, ) (*ApplicationContext, error)
NewApplicationContextRefactoredFromService creates an ApplicationContext from an application service. This is the typical entry point for command/query handlers.
Parameters:
- c: The Go context
- tenantID: The tenant ID for multi-tenancy
- locale: The user's locale
- s: The application service
Returns:
- A new ApplicationContext with transaction started
- Error if transaction begin or authentication fails
func (*ApplicationContext) AppendEventStore ¶
func (a *ApplicationContext) AppendEventStore(aggregate libdomain.Aggregate)
AppendEventStore collects events from an aggregate.
func (*ApplicationContext) Authenticate ¶
func (a *ApplicationContext) Authenticate(authService AuthService) error
Authenticate authenticates the user and sets up JWT claims.
func (*ApplicationContext) CacheManager ¶
func (a *ApplicationContext) CacheManager() *CacheManager
CacheManager returns the cache manager for this context.
func (*ApplicationContext) CleanCache ¶
func (a *ApplicationContext) CleanCache()
CleanCache removes non-invalidated cache entries.
func (*ApplicationContext) Commit ¶
func (a *ApplicationContext) Commit(err error) error
Commit commits the transaction and persists events and cache.
Parameters:
- err: Error from the workflow (if any)
Returns:
- The original error if provided, or any error from commit
This method: 1. Rolls back if err is provided 2. Registers and persists events 3. Commits the database transaction 4. Persists cache items 5. Dispatches events to streams
func (*ApplicationContext) Copy ¶
func (a *ApplicationContext) Copy() *ApplicationContext
Copy creates a shallow copy of the ApplicationContext.
func (*ApplicationContext) DomainEventPublisherInstance ¶
func (a *ApplicationContext) DomainEventPublisherInstance() *libdomain.DomainEventPublisherInstance
DomainEventPublisherInstance returns the domain event publisher instance.
func (*ApplicationContext) EventCollector ¶
func (a *ApplicationContext) EventCollector() *EventCollector
EventCollector returns the event collector for this context.
func (*ApplicationContext) FromDomain ¶
func (a *ApplicationContext) FromDomain() bool
FromDomain returns true if this context originated from the domain layer.
func (*ApplicationContext) GetDeterministicTestIds ¶
func (a *ApplicationContext) GetDeterministicTestIds(entityName string) int
GetDeterministicTestIds returns the test ID counter for an entity.
func (*ApplicationContext) GetTimestamp ¶
func (a *ApplicationContext) GetTimestamp() int64
GetTimestamp returns a monotonically increasing timestamp.
func (*ApplicationContext) IsSudo ¶
func (a *ApplicationContext) IsSudo() bool
IsSudo returns true if this context has sudo privileges.
func (*ApplicationContext) PublishPendingEvents ¶
func (a *ApplicationContext) PublishPendingEvents() error
PublishPendingEvents publishes all pending PreCommit events without committing the transaction. This triggers PreCommit subscriptions to execute synchronously before continuing the workflow.
Use this when you need child aggregates to be created via PreCommit subscriptions before the parent workflow continues (e.g., before calling methods that depend on the child aggregates).
Example: After creating a Specification aggregate, you may need SpecificationQuestionnaire and SpecificationConfiguration child aggregates to exist before calling methods that use them. Call PublishPendingEvents() after Add() to ensure PreCommit subscriptions create them.
Returns:
- Error if event publishing fails
func (*ApplicationContext) SetDeterministicTestIds ¶
func (a *ApplicationContext) SetDeterministicTestIds(entityName string, value int)
SetDeterministicTestIds sets the test ID counter for an entity.
func (*ApplicationContext) Sudo ¶
func (a *ApplicationContext) Sudo() libdomain.ApplicationContext
Sudo returns an ApplicationContext with sudo privileges for the domain layer.
func (*ApplicationContext) TransactionManager ¶
func (a *ApplicationContext) TransactionManager() *TransactionManager
TransactionManager returns the transaction manager for this context.
func (*ApplicationContext) WithContext ¶
func (a *ApplicationContext) WithContext(ctx context.Context) *ApplicationContext
WithContext creates a new ApplicationContext with a different Go context.
func (*ApplicationContext) WithSudo ¶
func (a *ApplicationContext) WithSudo() *ApplicationContext
WithSudo creates a new ApplicationContext with sudo privileges. Sudo mode bypasses certain authorization checks.
func (*ApplicationContext) WithTenantID ¶
func (a *ApplicationContext) WithTenantID(tenantID libdomain.TenantID) *ApplicationContext
WithTenantID creates a new ApplicationContext with a different tenant ID.
func (*ApplicationContext) Workflow ¶
func (a *ApplicationContext) Workflow() *libdomain.Workflow
Workflow returns the workflow context.
type ApplicationService ¶
type ApplicationService interface {
AuthService
TransactionClient() TransactionClient
CacheClient() CacheClient
DomainEventPublisher() *libdomain.DomainEventPublisher
}
type AuthService ¶
type CacheClient ¶
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager handles workflow-level caching of entities and query results. It is responsible for: - Storing cached items during a workflow - Managing cache invalidation - Persisting cache items to the cache client on commit - Cleaning up temporary cache entries
This component follows the Single Responsibility Principle by focusing solely on cache management, separate from other application context concerns.
func NewCacheManager ¶
func NewCacheManager(client CacheClient) *CacheManager
NewCacheManager creates a new CacheManager instance.
Parameters:
- client: The cache client for persistent storage (e.g., Redis)
func (*CacheManager) CleanCache ¶
func (c *CacheManager) CleanCache()
CleanCache removes non-invalidated cache entries from the workflow cache. This is typically called after a workflow completes to clean up temporary cache.
func (*CacheManager) Client ¶
func (c *CacheManager) Client() CacheClient
Client returns the underlying cache client.
func (*CacheManager) Commit ¶
func (c *CacheManager) Commit(ctx context.Context)
Commit persists all cached items to the cache client and processes invalidations. This method is called during transaction commit and: - Invalidates marked cache entries - Serializes and stores new cache items - Uses goroutines for parallel processing
Parameters:
- ctx: The context for cache client operations
This operation is performed concurrently for better performance.
func (*CacheManager) Get ¶
func (c *CacheManager) Get(model, key string) (*WorkflowCache, bool)
Get retrieves a cached item for a specific model and key.
Parameters:
- model: The aggregate or model type (e.g., "Project", "Theme")
- key: The cache key (typically includes entity ID)
Returns:
- The cached item if found
- Boolean indicating if the item was found
func (*CacheManager) GetCache ¶
func (c *CacheManager) GetCache() map[string]map[string]*WorkflowCache
GetCache returns the entire cache map. This is used for debugging and testing purposes.
func (*CacheManager) Invalidate ¶
func (c *CacheManager) Invalidate(model, key string)
Invalidate marks a cache entry for invalidation. The actual cache invalidation happens during commit.
Parameters:
- model: The aggregate or model type
- key: The cache key to invalidate
func (*CacheManager) Set ¶
func (c *CacheManager) Set(model, key string, cache *WorkflowCache)
Set stores an item in the workflow cache.
Parameters:
- model: The aggregate or model type
- key: The cache key
- cache: The workflow cache item to store
type DataTransferObjectDefinition ¶
type DataTransferObjectDefinition struct {
Name string
Properties []libdomain.PropertyDefinition
// contains filtered or unexported fields
}
func (*DataTransferObjectDefinition) AggregateDefinition ¶
func (t *DataTransferObjectDefinition) AggregateDefinition() *libdomain.AggregateDefinition
func (*DataTransferObjectDefinition) BoundedContext ¶
func (t *DataTransferObjectDefinition) BoundedContext() *libdomain.BoundedContext
func (*DataTransferObjectDefinition) DomainPackage ¶
func (t *DataTransferObjectDefinition) DomainPackage() string
func (*DataTransferObjectDefinition) DomainPath ¶
func (t *DataTransferObjectDefinition) DomainPath() string
func (*DataTransferObjectDefinition) FactoryTitle ¶
func (t *DataTransferObjectDefinition) FactoryTitle() string
func (*DataTransferObjectDefinition) GetAbstract ¶
func (t *DataTransferObjectDefinition) GetAbstract() bool
func (*DataTransferObjectDefinition) GetCommands ¶
func (t *DataTransferObjectDefinition) GetCommands() *libdomain.EntityCommandsDefinition
func (*DataTransferObjectDefinition) GetDisableDatabaseStore ¶
func (t *DataTransferObjectDefinition) GetDisableDatabaseStore() bool
func (*DataTransferObjectDefinition) GetDisableID ¶
func (t *DataTransferObjectDefinition) GetDisableID() bool
func (*DataTransferObjectDefinition) GetDisableMetadata ¶
func (t *DataTransferObjectDefinition) GetDisableMetadata() bool
func (*DataTransferObjectDefinition) GetKeys ¶
func (t *DataTransferObjectDefinition) GetKeys() []libdomain.Property
func (*DataTransferObjectDefinition) GetName ¶
func (t *DataTransferObjectDefinition) GetName() string
func (*DataTransferObjectDefinition) GetNoCache ¶
func (t *DataTransferObjectDefinition) GetNoCache() bool
func (*DataTransferObjectDefinition) GetProperties ¶
func (t *DataTransferObjectDefinition) GetProperties() []libdomain.Property
func (*DataTransferObjectDefinition) GetType ¶
func (t *DataTransferObjectDefinition) GetType() string
func (*DataTransferObjectDefinition) GetUseOneOf ¶
func (t *DataTransferObjectDefinition) GetUseOneOf() bool
func (*DataTransferObjectDefinition) HasDeletionGuard ¶
func (t *DataTransferObjectDefinition) HasDeletionGuard() bool
func (*DataTransferObjectDefinition) HasNameProperty ¶
func (f *DataTransferObjectDefinition) HasNameProperty() bool
HasNameProperty always returns false for DataTransferObjectDefinition.
func (*DataTransferObjectDefinition) HasTranslatable ¶
func (t *DataTransferObjectDefinition) HasTranslatable() bool
func (*DataTransferObjectDefinition) IdentityDomainPackage ¶
func (t *DataTransferObjectDefinition) IdentityDomainPackage() string
IdentityDomainPackage returns empty string for representations (use local package). This method exists to provide a unified interface with ReadModelDefinition.
func (*DataTransferObjectDefinition) IdentityTitle ¶
func (t *DataTransferObjectDefinition) IdentityTitle() string
IdentityTitle returns the title for identity types (same as Title for representations). This method exists to provide a unified interface with ReadModelDefinition.
func (*DataTransferObjectDefinition) ImportKeyNames ¶
func (t *DataTransferObjectDefinition) ImportKeyNames() []string
func (*DataTransferObjectDefinition) IsAggregateRoot ¶
func (t *DataTransferObjectDefinition) IsAggregateRoot() bool
func (*DataTransferObjectDefinition) IsEntity ¶
func (t *DataTransferObjectDefinition) IsEntity() bool
func (*DataTransferObjectDefinition) NaturalKeyName ¶
func (t *DataTransferObjectDefinition) NaturalKeyName() string
func (*DataTransferObjectDefinition) NaturalKeyNames ¶
func (t *DataTransferObjectDefinition) NaturalKeyNames() []string
func (*DataTransferObjectDefinition) NaturalKeyTitle ¶
func (t *DataTransferObjectDefinition) NaturalKeyTitle() string
func (*DataTransferObjectDefinition) NestedProperties ¶
func (t *DataTransferObjectDefinition) NestedProperties() []libdomain.Property
func (*DataTransferObjectDefinition) Prefix ¶
func (f *DataTransferObjectDefinition) Prefix() string
func (*DataTransferObjectDefinition) ScopeKeyNames ¶
func (t *DataTransferObjectDefinition) ScopeKeyNames() []string
func (*DataTransferObjectDefinition) Snake ¶
func (t *DataTransferObjectDefinition) Snake() string
func (*DataTransferObjectDefinition) StoredProperties ¶
func (t *DataTransferObjectDefinition) StoredProperties() []libdomain.Property
func (*DataTransferObjectDefinition) Subdomain ¶
func (t *DataTransferObjectDefinition) Subdomain() *libdomain.SubdomainDefinition
func (*DataTransferObjectDefinition) Title ¶
func (t *DataTransferObjectDefinition) Title() string
func (*DataTransferObjectDefinition) Upper ¶
func (f *DataTransferObjectDefinition) Upper() string
func (*DataTransferObjectDefinition) UseTenants ¶
func (t *DataTransferObjectDefinition) UseTenants() bool
type Definitions ¶
type Definitions struct {
Package string
Repository string
// contains filtered or unexported fields
}
func (*Definitions) ControlReferences ¶
func (ds *Definitions) ControlReferences()
func (*Definitions) GetByID ¶
func (ds *Definitions) GetByID(id string) *ServiceDefinition
GetByID return the specified definition by its ID.
func (*Definitions) Register ¶
func (ds *Definitions) Register(a *ServiceDefinition)
Register is used to register a new definition into the service.
func (*Definitions) RepositoryGen ¶
func (ds *Definitions) RepositoryGen() string
func (*Definitions) Slice ¶
func (ds *Definitions) Slice() []*ServiceDefinition
Slice return the definitions as a slice.
type EntityInterface ¶
type Event ¶
type Event struct {
Aggregate *libdomain.AggregateDefinition
Stream *libdomain.Stream
Data *EventData
}
type EventCollector ¶
type EventCollector struct {
// contains filtered or unexported fields
}
EventCollector manages the collection and storage of domain events during a workflow. It is responsible for: - Collecting events from aggregates - Tracking event versions - Preparing events for event store persistence - Organizing events by stream
This component follows the Single Responsibility Principle by focusing solely on event collection and management, separate from other application context concerns.
func NewEventCollector ¶
func NewEventCollector() *EventCollector
NewEventCollector creates a new EventCollector instance.
func (*EventCollector) AppendEventStore ¶
func (e *EventCollector) AppendEventStore(aggregate libdomain.Aggregate)
AppendEventStore collects events from an aggregate and prepares them for persistence. It: - Generates unique event IDs - Tracks aggregate versions - Captures event payloads and diffs - Associates events with their dispatch streams
Parameters:
- aggregate: The aggregate that generated the events
This method is called after domain operations that mutate aggregates.
func (*EventCollector) Clear ¶
func (e *EventCollector) Clear()
Clear removes all collected events. This should be called after events have been successfully persisted.
func (*EventCollector) EventCount ¶
func (e *EventCollector) EventCount() int
EventCount returns the number of events collected.
func (*EventCollector) GetEvents ¶
func (e *EventCollector) GetEvents() []*Event
GetEvents returns all collected events. This is typically called during transaction commit to persist events.
func (*EventCollector) GetEventsByStream ¶
func (e *EventCollector) GetEventsByStream() (map[string][]*Event, []*Event)
GetEventsByStream organizes events by their stream names. Returns:
- eventsPerStream: Map of stream name to events for that stream
- emptyEvents: Events that don't have an associated stream
This is used during event dispatch to group events by their destination streams.
func (*EventCollector) HasEvents ¶
func (e *EventCollector) HasEvents() bool
HasEvents returns true if there are events waiting to be persisted.
type EventData ¶
type EventData struct {
ID string `json:"id"`
TenantID string `json:"tenantID"`
AggregateName string `json:"aggregateName"`
AggregateID string `json:"aggregateID"`
AggregateVersion int `json:"aggregateVersion"`
Event string `json:"event"`
EventVersion int `json:"eventVersion"`
Current map[string]interface{} `json:"current"`
Diff map[string]interface{} `json:"diff"`
Payload map[string]interface{} `json:"payload"`
// UniqueReplyTo string `json:"uniqueReplyTo"`
OccurredAt time.Time `json:"occurredAt"`
OccurredBy string `json:"occurredBy"`
}
type ImportErrorInterface ¶
type ImportSuccessInterface ¶
type ImportSuccessInterface interface {
GetImportKey() string
GetEvents() []libdomain.DomainEvent
}
type NestedCommandGenerator ¶
type NestedCommandGenerator struct {
Method *libdomain.RequestDefinition
AggregateID string
NestedLevels []NestedEntityLevel // Chain of nested entities (e.g. [{choiceID, Choices}, {attributeFilterID, AttributeFilters}])
GenerateID bool // Set to true if method creates new nested entity (needs ID generation)
GeneratedIDEntity string // The entity name for ID generation (e.g. "QuestionChoiceAttributeFilter")
}
NestedCommandGenerator generates handler code for calling methods on nested entities
func (*NestedCommandGenerator) Generate ¶
func (c *NestedCommandGenerator) Generate() string
func (*NestedCommandGenerator) Imports ¶
func (c *NestedCommandGenerator) Imports() []*libdomain.PackageLocation
func (*NestedCommandGenerator) Type ¶
func (c *NestedCommandGenerator) Type() string
type NestedEntityLevel ¶
type NestedEntityLevel struct {
EntityID string // Parameter name for this entity's ID (e.g. "choiceID")
EntityField string // Collection field name (e.g. "Choices")
}
NestedEntityLevel represents one level in a nested entity chain
type OnDeleteValue ¶
type OnDeleteValue string
type ProtobufInterface ¶
type ProtobufInterface interface {
}
type RepeatedProperty ¶
func (*RepeatedProperty) DBType ¶
func (r *RepeatedProperty) DBType() *libdomain.DBType
func (*RepeatedProperty) GetInverseProperty ¶
func (r *RepeatedProperty) GetInverseProperty() string
func (*RepeatedProperty) GetLoadedPosition ¶
func (r *RepeatedProperty) GetLoadedPosition() int
func (*RepeatedProperty) GetLoadedPositionEntity ¶
func (r *RepeatedProperty) GetLoadedPositionEntity() int
func (*RepeatedProperty) GetName ¶
func (r *RepeatedProperty) GetName() string
func (*RepeatedProperty) GetPosition ¶
func (r *RepeatedProperty) GetPosition() int
func (*RepeatedProperty) GetPositionEntity ¶
func (r *RepeatedProperty) GetPositionEntity() int
func (*RepeatedProperty) GetPrimaryKey ¶
func (r *RepeatedProperty) GetPrimaryKey() bool
func (*RepeatedProperty) GetReferenceName ¶
func (r *RepeatedProperty) GetReferenceName() string
func (*RepeatedProperty) GetRequired ¶
func (r *RepeatedProperty) GetRequired() bool
func (r *RepeatedProperty) GetReference() TableInterface {
return r.Property.GetReference()
}
func (*RepeatedProperty) GetReturnDetailsInTests ¶
func (r *RepeatedProperty) GetReturnDetailsInTests() bool
func (*RepeatedProperty) GoNil ¶
func (r *RepeatedProperty) GoNil() string
func (*RepeatedProperty) GoType ¶
func (r *RepeatedProperty) GoType() string
func (*RepeatedProperty) GoTypeID ¶
func (r *RepeatedProperty) GoTypeID() string
func (*RepeatedProperty) GraphqlSchemaType ¶
func (r *RepeatedProperty) GraphqlSchemaType() string
func (*RepeatedProperty) GraphqlType ¶
func (r *RepeatedProperty) GraphqlType() string
func (*RepeatedProperty) IsNested ¶
func (r *RepeatedProperty) IsNested() bool
func (*RepeatedProperty) IsRepeated ¶
func (r *RepeatedProperty) IsRepeated() bool
func (*RepeatedProperty) IsStored ¶
func (r *RepeatedProperty) IsStored() bool
func (*RepeatedProperty) IsTranslatable ¶
func (r *RepeatedProperty) IsTranslatable() bool
func (*RepeatedProperty) JSONType ¶
func (r *RepeatedProperty) JSONType() string
func (*RepeatedProperty) LoadedPosition ¶
func (r *RepeatedProperty) LoadedPosition() int
func (*RepeatedProperty) LoadedPositionEntity ¶
func (r *RepeatedProperty) LoadedPositionEntity() int
func (*RepeatedProperty) NameWithoutID ¶
func (r *RepeatedProperty) NameWithoutID() string
func (*RepeatedProperty) Position ¶
func (r *RepeatedProperty) Position() int
func (*RepeatedProperty) PositionEntity ¶
func (r *RepeatedProperty) PositionEntity() int
func (*RepeatedProperty) ProtoTypeArg ¶
func (r *RepeatedProperty) ProtoTypeArg() string
func (r *RepeatedProperty) ProtoType() string {
prototype := r.Property.ProtoType()
if r.Property.Type() == "Many2oneType" {
prototype = strcase.ToCamel(r.Property.GetReference().Title())
}
return fmt.Sprintf("repeated %s", prototype)
}
func (*RepeatedProperty) SetPosition ¶
func (r *RepeatedProperty) SetPosition(position int)
func (r *RepeatedProperty) ProtoTypeOptional() string {
return r.ProtoType()
}
func (*RepeatedProperty) Snake ¶
func (r *RepeatedProperty) Snake() string
func (r *RepeatedProperty) SetReference(e TableInterface) {
r.Property.SetReference(e)
}
func (*RepeatedProperty) Title ¶
func (r *RepeatedProperty) Title() string
func (*RepeatedProperty) TitleWithoutID ¶
func (r *RepeatedProperty) TitleWithoutID() string
func (*RepeatedProperty) Type ¶
func (r *RepeatedProperty) Type() libdomain.PropertyType
func (*RepeatedProperty) Upper ¶
func (r *RepeatedProperty) Upper() string
type RequestDefinition ¶
type RequestDefinition struct {
Name string
Event string
OnFactory bool
Repository bool
Args []libdomain.ArgumentDefinition
Results []libdomain.ArgumentDefinition
TenantRequest bool
ExcludeFromDatasource bool
// Batchable marks this command as eligible for inclusion in an atomic batch
// (see go/application/batch/). Batchable commands share a single
// ApplicationContext/transaction when submitted via an executeBatch entrypoint.
// Only meaningful for commands (mutations), ignored for queries.
Batchable bool
Generator interface {
Generate() string
Imports() []*libdomain.PackageLocation
}
// contains filtered or unexported fields
}
func (*RequestDefinition) FromDomain ¶
func (f *RequestDefinition) FromDomain() bool
func (*RequestDefinition) GetArgs ¶
func (f *RequestDefinition) GetArgs() []libdomain.Argument
func (*RequestDefinition) GetName ¶
func (f *RequestDefinition) GetName() string
func (*RequestDefinition) GetResults ¶
func (f *RequestDefinition) GetResults() []libdomain.Argument
func (*RequestDefinition) GetService ¶
func (f *RequestDefinition) GetService() *ServiceDefinition
func (*RequestDefinition) IsBatchable ¶
func (f *RequestDefinition) IsBatchable() bool
func (*RequestDefinition) IsCommand ¶
func (f *RequestDefinition) IsCommand() bool
func (*RequestDefinition) SetFromDomain ¶
func (f *RequestDefinition) SetFromDomain(fromDomain bool)
func (*RequestDefinition) Title ¶
func (f *RequestDefinition) Title() string
func (*RequestDefinition) UseTenants ¶
func (f *RequestDefinition) UseTenants() bool
func (f *RequestDefinition) ResultTitle() string {
return strings.Title(f.ResultRepresentation)
}
type ServiceDefinition ¶
type ServiceDefinition struct {
Name string
// AggregateRoot *EntityDefinition
// Children []*EntityDefinition
// UseTenants bool
// entitiesByName map[string]*EntityDefinition
// ValueObjects []*ValueObjectDefinition
// valueObjectsByName map[string]*ValueObjectDefinition
ReferenceDefinition *ServiceDefinition
Queries []*RequestDefinition
Commands []*RequestDefinition
DataTransferObjects []*DataTransferObjectDefinition
Services []*ServiceDefinition
Repositories []*libdomain.RepositoryDefinition
// RepositoryMethods []*libdomain.RequestDefinition
ValueObjects []*libdomain.ValueObjectDefinition
// contains filtered or unexported fields
}
Definition is used to declare the information of a model, so it can generate its code.
func (*ServiceDefinition) ApplicationPackage ¶
func (a *ServiceDefinition) ApplicationPackage() string
func (*ServiceDefinition) ApplicationPath ¶
func (a *ServiceDefinition) ApplicationPath() string
func (*ServiceDefinition) GetCustomRequests ¶
func (a *ServiceDefinition) GetCustomRequests() []*RequestDefinition
func (a *AggregateDefinition) GetEntities() []*EntityDefinition {
EntitiesInAggregate := []*EntityDefinition{
a.AggregateRoot,
}
for _, c := range a.Children {
EntitiesInAggregate = append(EntitiesInAggregate, c)
}
return EntitiesInAggregate
}
func (a *AggregateDefinition) GetEntityByName(name string) *EntityDefinition {
return a.entitiesByName[name]
}
func (a *AggregateDefinition) GetValueObjectByName(name string) *ValueObjectDefinition {
return a.valueObjectsByName[name]
}
func (a *AggregateDefinition) GetCommandByName(name string) *RequestDefinition {
return a.commandsByName[name]
}
func (a *AggregateDefinition) GetTables() []TableInterface {
var tables []TableInterface
for _, c := range a.GetEntities() {
tables = append(tables, c)
}
for _, c := range a.ValueObjects {
tables = append(tables, c)
}
return tables
}
func (*ServiceDefinition) Snake ¶
func (a *ServiceDefinition) Snake() string
func (*ServiceDefinition) Title ¶
func (a *ServiceDefinition) Title() string
func (*ServiceDefinition) TitleWithPackage ¶
func (a *ServiceDefinition) TitleWithPackage() string
type StructuredImportError ¶
type StructuredImportError struct {
Column string // CSV column name, e.g. "parentID/.id"
Code string // error code, e.g. "REQUIRED_MISSING" or "FK_NOT_FOUND"
RawValue string // the offending value from the CSV row, if any
Message string // human-readable message
}
StructuredImportError is an error type emitted by generated ParseRootColumns when a known failure pattern (missing required field, FK lookup failure, etc.) can be attributed to a specific column with a code. The importer engine type-asserts to this type and surfaces the fields directly instead of parsing the message.
func (*StructuredImportError) Error ¶
func (e *StructuredImportError) Error() string
Error implements the error interface.
type TableInterface ¶
type TableInterface interface {
GetName() string
Title() string
Snake() string
Upper() string
GetType() string
IsEntity() bool
UseTenants() bool
GetDisableID() bool
GetDisableMetadata() bool
GetDisableDatabaseStore() bool
GetUseOneOf() bool
StoredProperties() []libdomain.PropertyDefinition
NestedProperties() []libdomain.PropertyDefinition
// GetCommands() *EntityCommandsDefinition
GetKeys() []libdomain.PropertyDefinition
IsAggregateRoot() bool
HasTranslatable() bool
GetAbstract() bool
GetNoCache() bool
DomainPath() string
}
type TransactionClient ¶
type TransactionClient interface {
BeginTransaction(*ApplicationContext, bool) error
RollbackTransaction(*ApplicationContext) error
CommitTransaction(*ApplicationContext) error
RegisterEvents(*ApplicationContext, interface{}, []*Event) error
MarkDispatchedEvents(*ApplicationContext, []*Event) error
GetAggregateEvents(*ApplicationContext, *libdomain.AggregateDefinition, string) ([]*Event, error)
GetAggregateHistory(*ApplicationContext, *libdomain.AggregateDefinition, string) ([]*libdomain.EventHistory, error)
GetUserEvents(*ApplicationContext, string, []string, int, string) ([]*Event, error)
}
type TransactionManager ¶
type TransactionManager struct {
// contains filtered or unexported fields
}
TransactionManager manages database transactions and event persistence. It is responsible for: - Beginning, committing, and rolling back transactions - Registering events in the event store - Dispatching events to streams - Marking events as dispatched
This component follows the Single Responsibility Principle by focusing solely on transaction and event persistence management, separate from other concerns.
func NewTransactionManager ¶
func NewTransactionManager(client TransactionClient) *TransactionManager
NewTransactionManager creates a new TransactionManager instance.
Parameters:
- client: The transaction client that handles the actual database transactions
func (*TransactionManager) Begin ¶
func (t *TransactionManager) Begin(ctx *ApplicationContext, readWrite bool) error
Begin starts a new database transaction.
Parameters:
- ctx: The application context
- readWrite: True for read-write transaction, false for read-only
Returns:
- Error if the transaction cannot be started
func (*TransactionManager) Client ¶
func (t *TransactionManager) Client() TransactionClient
Client returns the underlying TransactionClient.
func (*TransactionManager) Commit ¶
func (t *TransactionManager) Commit(ctx *ApplicationContext, events []*Event) error
Commit commits the current transaction and handles event persistence and dispatch. This method: 1. Publishes pending pre-commit events 2. Registers events in the event store (including events from pre-commit handlers) 3. Commits the database transaction 4. Dispatches events to their streams 5. Marks events as dispatched
Parameters:
- ctx: The application context
- events: The events to persist and dispatch
Returns:
- Error if commit fails (transaction will be rolled back)
Note: Event dispatch happens asynchronously after transaction commit
func (*TransactionManager) GetTransaction ¶
func (t *TransactionManager) GetTransaction() interface{}
GetTransaction returns the current transaction object. This is used by repositories that need direct access to the transaction.
func (*TransactionManager) Rollback ¶
func (t *TransactionManager) Rollback(ctx *ApplicationContext) error
Rollback rolls back the current transaction. This is called when an error occurs during the workflow.
Parameters:
- ctx: The application context
Returns:
- Error if rollback fails
func (*TransactionManager) SetTransaction ¶
func (t *TransactionManager) SetTransaction(transaction interface{})
SetTransaction sets the current transaction object. This is called by the transaction client after beginning a transaction.
type WorkflowCache ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package batch provides a runtime primitive for executing multiple aggregate commands atomically within a single ApplicationContext / database transaction.
|
Package batch provides a runtime primitive for executing multiple aggregate commands atomically within a single ApplicationContext / database transaction. |
|
natsworker
Package natsworker provides NATS-based publishing and worker wiring for async imports.
|
Package natsworker provides NATS-based publishing and worker wiring for async imports. |
|
pgjobstore
Package pgjobstore is a PostgreSQL-backed implementation of importer.JobStore that integrates with the stack framework's DatasourceClient.
|
Package pgjobstore is a PostgreSQL-backed implementation of importer.JobStore that integrates with the stack framework's DatasourceClient. |