adl

package
v0.0.0-...-797e501 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PMemory PersistenceType = "in-memory"
	PFile                   = "file"
	PMySQL                  = "mysql"
)
View Source
const (
	// DTO is a data transfer stereotype.
	DTO = "dto"

	// Cfg is a configuration stereotype.
	Cfg = "cfg"

	// ServiceComponent is a service stereotype.
	ServiceComponent = "service"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundedContext

type BoundedContext struct {
	Name    token.String
	Path    token.String
	Core    []*Package // multiple core packages are allowed, to allow arbitrary large and complex nested (sub or supporting) domains.
	Usecase []*Package // same for the use cases
}

A BoundedContext is a cross-cutting thing, which is referenced from various places and contains its own ubiquitous language (== glossary).

func NewBoundedContext

func NewBoundedContext(name, path string) *BoundedContext

func (*BoundedContext) AddCore

func (d *BoundedContext) AddCore(l ...*Package) *BoundedContext

func (*BoundedContext) AddUsecase

func (d *BoundedContext) AddUsecase(l *Package) *BoundedContext

func (*BoundedContext) Normalize

func (d *BoundedContext) Normalize(ctx Ctx)

Normalize rewrites all path like things.

type CRUD

type CRUD struct {
	EntityType *TypeDecl // the actual data type or io.ReadWriter for a generic stream api
	IDType     *TypeDecl // optional custom id type (empty if ID field in EntityType must be used)

	Persistence                              PersistenceType
	InsertOne, FindOne, UpdateOne, DeleteOne bool
	CountAll, FindAll, IterateAll            bool
}

CRUD represents an autogenerated piece of code to manage entities.

func NewCRUD

func NewCRUD(entityType *TypeDecl, IDType *TypeDecl, persistence PersistenceType, createOne bool, findOne bool, updateOne bool, deleteOne bool, countAll bool, findAll bool, iterateAll bool) *CRUD

func (*CRUD) Normalize

func (i *CRUD) Normalize(ctx Ctx)

type Ctx

type Ctx struct {
	Mod string
	BC  string
}

type Error

type Error struct {
	Comment token.String
	Name    token.String
	Fields  []*Field
}

func NewError

func NewError(name, comment string) *Error

func (*Error) AddFields

func (d *Error) AddFields(f ...*Field) *Error

func (*Error) Normalize

func (d *Error) Normalize(ctx Ctx)

type Executable

type Executable struct {
	Comment             token.String
	Name                token.String
	BoundedContextPaths []token.String
}

An Executable defines an entry point into the application. At least Java and Go support an arbitrary set of main entry points.

func NewExecutable

func NewExecutable(name, comment string) *Executable

func (*Executable) Application

func (e *Executable) Application(paths ...string) *Executable

func (*Executable) Normalize

func (e *Executable) Normalize(ctx Ctx)

type Field

type Field struct {
	Comment        token.String
	Name           token.String
	Type           *TypeDecl
	Private        bool
	CfgCmdLineFlag bool
}

func NewField

func NewField(name, comment string, decl *TypeDecl) *Field

func NewPrivateField

func NewPrivateField(name, comment string, decl *TypeDecl) *Field

func (*Field) Normalize

func (f *Field) Normalize(ctx Ctx)

func (*Field) SetCfgCmdLineFlag

func (f *Field) SetCfgCmdLineFlag(flag bool) *Field

SetCfgCmdLineFlag is only valid within a struct configuration stereotype.

type Generator

type Generator struct {
	Go     *Golang
	OutDir token.String // the target directory to (re) write the module
}

A Generator describes how this project should be generated.

func NewGenerator

func NewGenerator() *Generator

func (*Generator) SetGo

func (g *Generator) SetGo(d *Golang) *Generator

func (*Generator) SetOutDir

func (g *Generator) SetOutDir(dir string) *Generator

type Glossary

type Glossary struct {
	Terms map[string]Term
}

func NewGlossary

func NewGlossary() *Glossary

func (*Glossary) Put

func (g *Glossary) Put(key, val string) *Glossary

type GoDist

type GoDist struct {
	Arch token.String
	Os   token.String
}

type Golang

type Golang struct {
	Module   token.String // the name of the go module, e.g. github.com/worldiety/supportiety
	GoDist   []*GoDist
	Requires []token.String // require directives
}

Golang describes how a Go project (or module) must be created or updated.

func NewGolang

func NewGolang() *Golang

func (*Golang) AddDist

func (g *Golang) AddDist(goos, goarch string) *Golang

func (*Golang) Require

func (g *Golang) Require(dep string) *Golang

func (*Golang) SetModName

func (g *Golang) SetModName(name string) *Golang

type Injection

type Injection struct {
	Comment    token.String // why is this needed?
	Name       token.String // usually the field name, but also as a reference/documentation name
	Stereotype token.String // optional stereotype to indicate the type.
	Type       *TypeDecl
}

func NewInjection

func NewInjection(name, comment, stereotype string, typ *TypeDecl) *Injection

func (*Injection) Normalize

func (t *Injection) Normalize(ctx Ctx)

type Interface

type Interface struct {
	Comment token.String
	Name    token.String
	Methods []*Method
	CRUDs   []*CRUD
}

func NewInterface

func NewInterface(name, comment string) *Interface

func (*Interface) AddCRUDImpl

func (i *Interface) AddCRUDImpl(crud ...*CRUD) *Interface

func (*Interface) AddMethods

func (i *Interface) AddMethods(m ...*Method) *Interface

func (*Interface) Normalize

func (i *Interface) Normalize(ctx Ctx)

type Method

type Method struct {
	Comment     token.String
	Name        token.String
	In          []*Param
	Out         []*Param
	Errors      []*TypeDecl // sum type of error types. Non-qualified names are always resolved to package local declarations or fail.
	StubDefault bool        // StubDefault instructs the generator to emit an abstract or default implementation
}

func NewMethod

func NewMethod(name, comment string) *Method

func (*Method) AddErrors

func (m *Method) AddErrors(names ...*TypeDecl) *Method

func (*Method) AddIn

func (m *Method) AddIn(name, comment string, decl *TypeDecl) *Method

func (*Method) AddOut

func (m *Method) AddOut(name, comment string, decl *TypeDecl) *Method

func (*Method) Normalize

func (m *Method) Normalize(ctx Ctx)

func (*Method) OutParams

func (m *Method) OutParams(p ...*Param) *Method

type Module

type Module struct {
	Preamble        Preamble
	Name            token.String // the name of the project
	Comment         token.String
	Generator       *Generator
	BoundedContexts []*BoundedContext
	Executables     []*Executable
}

A Module is e.g. a server application, a frontend or a shared library.

func NewModule

func NewModule(name, comment string) *Module

func (*Module) AddBoundedContexts

func (p *Module) AddBoundedContexts(d ...*BoundedContext) *Module

func (*Module) AddExecutables

func (p *Module) AddExecutables(e ...*Executable) *Module

func (*Module) SetGenerator

func (p *Module) SetGenerator(g *Generator) *Module

func (*Module) SetLicense

func (p *Module) SetLicense(str string) *Module

type Package

type Package struct {
	Comment      token.String
	Name         token.String
	Repositories []*Interface
	Services     []*Service
	DTOs         []*Struct
	Errors       []*Error
}

func NewPackage

func NewPackage(name, comment string) *Package

func (*Package) AddErrors

func (p *Package) AddErrors(d ...*Error) *Package

func (*Package) AddRepositories

func (p *Package) AddRepositories(r ...*Interface) *Package

func (*Package) AddServices

func (p *Package) AddServices(s ...*Service) *Package

func (*Package) AddStructs

func (p *Package) AddStructs(d ...*Struct) *Package

func (*Package) Normalize

func (p *Package) Normalize(ctx Ctx)

type Param

type Param struct {
	Comment token.String
	Name    token.String
	Type    *TypeDecl
}

func (*Param) Normalize

func (p *Param) Normalize(ctx Ctx)

type PersistenceType

type PersistenceType string

type Preamble

type Preamble struct {
	Generator string
	License   string
}

type Project

type Project struct {
	Name     token.String
	Comment  token.String
	Modules  []*Module
	Glossary *Glossary
}

A Project has multiple modules, like libraries, servers or clients, frontends or backends.

func NewProject

func NewProject(name, comment string) *Project

func (*Project) AddModules

func (w *Project) AddModules(p ...*Module) *Project

func (*Project) PutGlossary

func (w *Project) PutGlossary(key, val string) *Project

type Service

type Service struct {
	Component *Struct
}

func NewService

func NewService(name, comment string) *Service

func (*Service) AddFields

func (s *Service) AddFields(f ...*Field) *Service

func (*Service) AddInjections

func (s *Service) AddInjections(m ...*Injection) *Service

func (*Service) AddMethods

func (s *Service) AddMethods(m ...*Method) *Service

func (*Service) Normalize

func (s *Service) Normalize(ctx Ctx)

type Struct

type Struct struct {
	Comment    token.String
	Name       token.String
	Stereotype token.String
	Fields     []*Field
	Methods    []*Method
	Inject     []*Injection // optional and arbitrary types to inject like configuration or other services.
}

func NewConfig

func NewConfig(name, comment string) *Struct

func NewDTO

func NewDTO(name, comment string) *Struct

func NewStruct

func NewStruct(name, comment, stereotype string) *Struct

func (*Struct) AddFields

func (d *Struct) AddFields(f ...*Field) *Struct

func (*Struct) Normalize

func (d *Struct) Normalize(ctx Ctx)

type Term

type Term struct {
	Ident       token.String
	Description token.String
}

type TypeDecl

type TypeDecl struct {
	Name       token.String
	TypeParams []*TypeDecl
}

A TypeDecl is the generified declaration of named types, consisting of full qualified name, a pointer flag and optionally nested other type parameters.

func NewTypeDecl

func NewTypeDecl(name string, typeDecl ...*TypeDecl) *TypeDecl

func (*TypeDecl) IsArray

func (t *TypeDecl) IsArray() bool

IsArray checks for [] and expects exactly 2 TypeParams (first is len, second the actual type).

func (*TypeDecl) IsMap

func (t *TypeDecl) IsMap() bool

IsMap checks for map! and expects exactly 2 TypeParams.

func (*TypeDecl) IsPtr

func (t *TypeDecl) IsPtr() bool

IsPtr checks for * and expects exactly 1 TypeParam.

func (*TypeDecl) IsSlice

func (t *TypeDecl) IsSlice() bool

IsSlice checks for [] and expects exactly 1 TypeParam.

func (*TypeDecl) Normalize

func (t *TypeDecl) Normalize(ctx Ctx)

Jump to

Keyboard shortcuts

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