libapplication

package
v0.0.0-...-437541a Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const OnDeleteCascade = OnDeleteValue("CASCADE")
View Source
const OnDeleteProtect = OnDeleteValue("PROTECT")
View Source
const OnDeleteSetNull = OnDeleteValue("SET NULL")
View Source
const RepeatedPropertyType = libdomain.PropertyType("RepeatedPropertyType")
View Source
const STRING = "string"

STRING is a contains reprensenting the widely used string type.

Variables

View Source
var SetAggregateIDProperty func(string) libdomain.Property

Functions

This section is empty.

Types

type ApplicationContext

type ApplicationContext struct {
	TransactionClient TransactionClient
	Transaction       interface{}
	CacheClient       CacheClient
	// contains filtered or unexported fields
}

func NewApplicationContext

func NewApplicationContext(ctx context.Context, transactionClient TransactionClient, cacheClient CacheClient, domainEventPublisher *libdomain.DomainEventPublisher, fromDomain bool) *ApplicationContext

func NewApplicationContextFromService

func NewApplicationContextFromService(c context.Context, tenantID string, locale string, s ApplicationService) (*ApplicationContext, error)

func (*ApplicationContext) AppendEventStore

func (a *ApplicationContext) AppendEventStore(aggregate libdomain.Aggregate)

func (*ApplicationContext) Authenticate

func (a *ApplicationContext) Authenticate(authService AuthService) error

func (*ApplicationContext) Commit

func (r *ApplicationContext) Commit(err error) error

func (*ApplicationContext) DomainEventPublisherInstance

func (a *ApplicationContext) DomainEventPublisherInstance() *libdomain.DomainEventPublisherInstance

func (*ApplicationContext) FromDomain

func (a *ApplicationContext) FromDomain() bool

func (*ApplicationContext) GetCache

func (w *ApplicationContext) GetCache() map[string]map[string]*WorkflowCache

func (*ApplicationContext) GetTimestamp

func (w *ApplicationContext) GetTimestamp() int64

func (*ApplicationContext) SetWorkflow

func (w *ApplicationContext) SetWorkflow(workflow *libdomain.Workflow)

func (*ApplicationContext) Workflow

func (w *ApplicationContext) Workflow() *libdomain.Workflow

type ApplicationService

type ApplicationService interface {
	AuthService
	TransactionClient() TransactionClient
	CacheClient() CacheClient
	DomainEventPublisher() *libdomain.DomainEventPublisher
}

type AuthService

type AuthService interface {
	Authenticate(*ApplicationContext, string) (string, string, []interface{}, error)
}

type CacheClient

type CacheClient interface {
	Set(context.Context, string, []byte, time.Duration) error
	Get(context.Context, string) ([]byte, error)
	Invalidate(context.Context, string) error
}

type CommandFromDomainCreate

type CommandFromDomainCreate struct {
	Aggregate   *libdomain.AggregateDefinition
	NewPackage  *libdomain.PackageLocation
	NewFunction string
	Args        []string
}

func (*CommandFromDomainCreate) Generate

func (c *CommandFromDomainCreate) Generate() string

func (*CommandFromDomainCreate) Imports

func (*CommandFromDomainCreate) Type

func (c *CommandFromDomainCreate) Type() string

type CommandFromDomainMethod

type CommandFromDomainMethod struct {
	Method      *libdomain.CustomRequest
	AggregateID string
	ArgsMapping interface {
		Generate() string
	}
}

func (*CommandFromDomainMethod) Generate

func (c *CommandFromDomainMethod) Generate() string

func (*CommandFromDomainMethod) Imports

func (*CommandFromDomainMethod) Type

func (c *CommandFromDomainMethod) Type() string

type CustomRequest

type CustomRequest struct {
	Name          string
	Event         string
	OnFactory     bool
	Repository    bool
	Args          []libdomain.ArgsInterface
	Results       []libdomain.ArgsInterface
	TenantRequest bool

	Generator interface {
		Generate() string
		Imports() []*libdomain.PackageLocation
	}
	// contains filtered or unexported fields
}

func (*CustomRequest) FromDomain

func (f *CustomRequest) FromDomain() bool

func (*CustomRequest) GetName

func (f *CustomRequest) GetName() string

func (*CustomRequest) IsCommand

func (f *CustomRequest) IsCommand() bool

func (*CustomRequest) SetFromDomain

func (f *CustomRequest) SetFromDomain(fromDomain bool)

func (*CustomRequest) Title

func (f *CustomRequest) Title() string

func (*CustomRequest) UseTenants

func (f *CustomRequest) UseTenants() bool
func (f *CustomRequest) ResultTitle() string {
	return strings.Title(f.ResultRepresentation)
}

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 EntityInterface interface {
	GetID() string
	GetExternalID() string
}

type Event

type Event struct {
	Aggregate *libdomain.AggregateDefinition
	Stream    *libdomain.Stream
	Data      *EventData
}

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 ImportErrorInterface interface {
	GetCode() string
	GetError() string
}

type ImportSuccessInterface

type ImportSuccessInterface interface {
	GetCode() string
	GetEvents() []libdomain.DomainEvent
}

type OnDeleteValue

type OnDeleteValue string

type ProtobufInterface

type ProtobufInterface interface {
}

type RepeatedProperty

type RepeatedProperty struct {
	Property libdomain.Property
}

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) GetLoadedPositionMany2one

func (r *RepeatedProperty) GetLoadedPositionMany2one() int

func (*RepeatedProperty) GetName

func (r *RepeatedProperty) GetName() string

func (*RepeatedProperty) GetPosition

func (r *RepeatedProperty) GetPosition() int

func (*RepeatedProperty) GetPositionMany2one

func (r *RepeatedProperty) GetPositionMany2one() 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) LoadedPositionMany2one

func (r *RepeatedProperty) LoadedPositionMany2one() int

func (*RepeatedProperty) NameWithoutID

func (r *RepeatedProperty) NameWithoutID() string

func (*RepeatedProperty) Position

func (r *RepeatedProperty) Position() int

func (*RepeatedProperty) PositionMany2one

func (r *RepeatedProperty) PositionMany2one() 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 (*RepeatedProperty) Upper

func (r *RepeatedProperty) Upper() string

type RepresentationDefinition

type RepresentationDefinition struct {
	Name       string
	Properties []libdomain.Property
	// contains filtered or unexported fields
}

func (*RepresentationDefinition) AggregateDefinition

func (t *RepresentationDefinition) AggregateDefinition() *libdomain.AggregateDefinition

func (*RepresentationDefinition) DomainPackage

func (t *RepresentationDefinition) DomainPackage() string

func (*RepresentationDefinition) DomainPath

func (t *RepresentationDefinition) DomainPath() string

func (*RepresentationDefinition) GetAbstract

func (t *RepresentationDefinition) GetAbstract() bool

func (*RepresentationDefinition) GetCommands

func (*RepresentationDefinition) GetDisableDatabaseStore

func (t *RepresentationDefinition) GetDisableDatabaseStore() bool

func (*RepresentationDefinition) GetDisableDatetime

func (t *RepresentationDefinition) GetDisableDatetime() bool

func (*RepresentationDefinition) GetDisableID

func (t *RepresentationDefinition) GetDisableID() bool

func (*RepresentationDefinition) GetKeys

func (*RepresentationDefinition) GetName

func (t *RepresentationDefinition) GetName() string

func (*RepresentationDefinition) GetNoCache

func (t *RepresentationDefinition) GetNoCache() bool

func (*RepresentationDefinition) GetProperties

func (t *RepresentationDefinition) GetProperties() []libdomain.Property

func (*RepresentationDefinition) GetType

func (t *RepresentationDefinition) GetType() string

func (*RepresentationDefinition) GetUseOneOf

func (t *RepresentationDefinition) GetUseOneOf() bool

func (*RepresentationDefinition) HasTranslatable

func (t *RepresentationDefinition) HasTranslatable() bool

func (*RepresentationDefinition) IsAggregateRoot

func (t *RepresentationDefinition) IsAggregateRoot() bool

func (*RepresentationDefinition) IsEntity

func (t *RepresentationDefinition) IsEntity() bool

func (*RepresentationDefinition) NestedProperties

func (t *RepresentationDefinition) NestedProperties() []libdomain.Property

func (*RepresentationDefinition) Snake

func (t *RepresentationDefinition) Snake() string

func (*RepresentationDefinition) StoredProperties

func (t *RepresentationDefinition) StoredProperties() []libdomain.Property

func (*RepresentationDefinition) Title

func (t *RepresentationDefinition) Title() string

func (*RepresentationDefinition) UniquePropertyName

func (t *RepresentationDefinition) UniquePropertyName() string

func (*RepresentationDefinition) UniquePropertyTitle

func (t *RepresentationDefinition) UniquePropertyTitle() string

func (*RepresentationDefinition) Upper

func (f *RepresentationDefinition) Upper() string

func (*RepresentationDefinition) UseTenants

func (t *RepresentationDefinition) UseTenants() bool

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             []*CustomRequest
	Commands            []*CustomRequest
	Representations     []*RepresentationDefinition
	Services            []*ServiceDefinition
	Repositories        []*libdomain.RepositoryDefinition
	// 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() []*CustomRequest
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) *CustomRequest {
	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 TableInterface

type TableInterface interface {
	GetName() string
	Title() string
	Snake() string
	Upper() string
	GetType() string
	IsEntity() bool
	UseTenants() bool
	GetDisableID() bool
	GetDisableDatetime() bool
	GetDisableDatabaseStore() bool
	GetUseOneOf() bool
	StoredProperties() []libdomain.Property
	NestedProperties() []libdomain.Property
	// GetCommands() *EntityCommandsDefinition
	GetKeys() []libdomain.Property
	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
	MarkDispatchedEvent(*ApplicationContext, *Event) error
	GetAggregateEvents(*ApplicationContext, *libdomain.AggregateDefinition, string) ([]*Event, error)
	GetAggregateHistory(*ApplicationContext, *libdomain.AggregateDefinition, string) ([]*libdomain.EventHistory, error)
}

type WorkflowCache

type WorkflowCache struct {
	CacheClient
	Key                     string
	ToInvalidate            bool
	Item                    proto.Message
	PurgeOutOfCacheFunction func(proto.Message)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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