Documentation
¶
Index ¶
- func RegisterElasticsearch(registry *Registry)
- type BaseProcessor
- type ComponentInfo
- type ComponentType
- type DBInfo
- type DefaultProcessor
- func (p *DefaultProcessor) Close() string
- func (p *DefaultProcessor) ComposeEnv() string
- func (p *DefaultProcessor) Config() string
- func (p *DefaultProcessor) ConfigEnv() string
- func (p *DefaultProcessor) ConfigField() string
- func (p *DefaultProcessor) ConfigFieldName() string
- func (p *DefaultProcessor) Constructor() string
- func (p *DefaultProcessor) DockerCompose() string
- func (p *DefaultProcessor) FillStructField() string
- func (p *DefaultProcessor) Import() string
- func (p *DefaultProcessor) InitInAppConstructor() string
- func (p *DefaultProcessor) MigrateFileData() []byte
- func (p *DefaultProcessor) StructField() string
- type InfraInfo
- type Opt
- type Processor
- func NewAerospikeProcessor() Processor
- func NewElasticsearchProcessor() Processor
- func NewEtcdProcessor() Processor
- func NewKafkaProcessor() Processor
- func NewMemcacheProcessor() Processor
- func NewMongoDBProcessor() Processor
- func NewMySQLProcessor() Processor
- func NewNatsProcessor() Processor
- func NewPostgresProcessor() Processor
- func NewRabbitMQProcessor() Processor
- func NewRedisProcessor() Processor
- type ProcessorOption
- func WithComposeEnv(fn func(cfg *config.ProjectConfig) string) ProcessorOption
- func WithConfigEnv(code string) ProcessorOption
- func WithConfigField(code string) ProcessorOption
- func WithConfigFieldName(code string) ProcessorOption
- func WithFillStructField(code string) ProcessorOption
- func WithImport(fn func(cfg *config.ProjectConfig) string) ProcessorOption
- func WithMigrateFileData(data []byte) ProcessorOption
- func WithStructField(code string) ProcessorOption
- type Registry
- func (r *Registry) GetDB(code string) ComponentInfo
- func (r *Registry) GetInfra(code string) ComponentInfo
- func (r *Registry) ListDBs() []*ComponentInfo
- func (r *Registry) ListInfras() []*ComponentInfo
- func (r *Registry) RegisterComponent(info ComponentInfo)
- func (r *Registry) RegisterDB(code, title string, processor Processor, order int)
- func (r *Registry) RegisterInfra(code, title string, processor Processor, order int)
- func (r *Registry) UpdateConfig(cfg *config.ProjectConfig)
- type RegistryOption
- func WithAerospike() RegistryOption
- func WithComponent(info ComponentInfo) RegistryOption
- func WithDB(code, title string, processor Processor, order int) RegistryOption
- func WithElasticsearch() RegistryOption
- func WithEtcd() RegistryOption
- func WithInfra(code, title string, processor Processor, order int) RegistryOption
- func WithKafka() RegistryOption
- func WithMemcache() RegistryOption
- func WithMongo() RegistryOption
- func WithMySQL() RegistryOption
- func WithNats() RegistryOption
- func WithPostgres() RegistryOption
- func WithRabbitMQ() RegistryOption
- func WithRedis() RegistryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterElasticsearch ¶ added in v1.10.0
func RegisterElasticsearch(registry *Registry)
RegisterElasticsearch demonstrates how to register a component at runtime
Types ¶
type BaseProcessor ¶ added in v1.3.1
type BaseProcessor struct {
// contains filtered or unexported fields
}
func (*BaseProcessor) SetConfig ¶ added in v1.3.1
func (b *BaseProcessor) SetConfig(cfg *config.ProjectConfig)
type ComponentInfo ¶ added in v1.10.0
type ComponentInfo struct {
Code string
Title string
Type ComponentType
Processor Processor
Order int
}
ComponentInfo contains information about a component
type ComponentType ¶ added in v1.10.0
type ComponentType int
ComponentType represents the type of a component (DB or Infra)
const ( // DBComponent represents a database component DBComponent ComponentType = iota // InfraComponent represents an infrastructure component InfraComponent )
type DefaultProcessor ¶ added in v1.10.0
type DefaultProcessor struct {
BaseProcessor
// contains filtered or unexported fields
}
DefaultProcessor provides default implementations for all Processor methods
func NewDefaultProcessor ¶ added in v1.10.0
func NewDefaultProcessor(tmpl string, opts ...ProcessorOption) *DefaultProcessor
NewDefaultProcessor creates a new DefaultProcessor with the given options
func (*DefaultProcessor) Close ¶ added in v1.10.0
func (p *DefaultProcessor) Close() string
Close implements Processor.Close
func (*DefaultProcessor) ComposeEnv ¶ added in v1.10.0
func (p *DefaultProcessor) ComposeEnv() string
ComposeEnv implements Processor.ComposeEnv
func (*DefaultProcessor) Config ¶ added in v1.10.0
func (p *DefaultProcessor) Config() string
Config implements Processor.Config
func (*DefaultProcessor) ConfigEnv ¶ added in v1.10.0
func (p *DefaultProcessor) ConfigEnv() string
ConfigEnv implements Processor.ConfigEnv
func (*DefaultProcessor) ConfigField ¶ added in v1.10.0
func (p *DefaultProcessor) ConfigField() string
ConfigField implements Processor.ConfigField
func (*DefaultProcessor) ConfigFieldName ¶ added in v1.10.0
func (p *DefaultProcessor) ConfigFieldName() string
ConfigFieldName implements Processor.ConfigFieldName
func (*DefaultProcessor) Constructor ¶ added in v1.10.0
func (p *DefaultProcessor) Constructor() string
Constructor implements Processor.Constructor
func (*DefaultProcessor) DockerCompose ¶ added in v1.10.0
func (p *DefaultProcessor) DockerCompose() string
DockerCompose implements Processor.DockerCompose
func (*DefaultProcessor) FillStructField ¶ added in v1.10.0
func (p *DefaultProcessor) FillStructField() string
FillStructField implements Processor.FillStructField
func (*DefaultProcessor) Import ¶ added in v1.10.0
func (p *DefaultProcessor) Import() string
Import implements Processor.Import
func (*DefaultProcessor) InitInAppConstructor ¶ added in v1.10.0
func (p *DefaultProcessor) InitInAppConstructor() string
InitInAppConstructor implements Processor.InitInAppConstructor
func (*DefaultProcessor) MigrateFileData ¶ added in v1.10.0
func (p *DefaultProcessor) MigrateFileData() []byte
MigrateFileData implements Processor.MigrateFileData
func (*DefaultProcessor) StructField ¶ added in v1.10.0
func (p *DefaultProcessor) StructField() string
StructField implements Processor.StructField
type InfraInfo ¶
type InfraInfo = ComponentInfo
type Opt ¶ added in v1.3.1
type Opt = RegistryOption
type Processor ¶
type Processor interface {
// SetConfig sets the project configuration
SetConfig(cfg *config.ProjectConfig)
// Import returns the import statements needed for this component
Import() string
// Config returns the configuration struct definition
Config() string
// ConfigField returns the field definition for the configuration struct
ConfigField() string
// ConfigFieldName returns the name of the configuration field
ConfigFieldName() string
// Constructor returns the constructor code
Constructor() string
// InitInAppConstructor returns the code to initialize this component in the app constructor
InitInAppConstructor() string
// StructField returns the field definition for the app struct
StructField() string
// FillStructField returns the code to fill the app struct field
FillStructField() string
// Close returns the code to close/cleanup this component
Close() string
// DockerCompose returns the docker-compose service definition
DockerCompose() string
// ComposeEnv returns the environment variables for docker-compose
ComposeEnv() string
// ConfigEnv returns the environment variables for the configuration
ConfigEnv() string
// MigrateFileData returns the migration file data
MigrateFileData() []byte
}
Processor defines the interface for infrastructure component processors
func NewAerospikeProcessor ¶ added in v1.10.0
func NewAerospikeProcessor() Processor
NewAerospikeProcessor creates a new processor for Aerospike
func NewElasticsearchProcessor ¶ added in v1.10.0
func NewElasticsearchProcessor() Processor
NewElasticsearchProcessor creates a new processor for Elasticsearch
func NewEtcdProcessor ¶ added in v1.10.0
func NewEtcdProcessor() Processor
NewEtcdProcessor creates a new processor for Etcd
func NewKafkaProcessor ¶ added in v1.10.0
func NewKafkaProcessor() Processor
NewKafkaProcessor creates a new processor for Kafka
func NewMemcacheProcessor ¶ added in v1.10.0
func NewMemcacheProcessor() Processor
NewMemcacheProcessor creates a new processor for Memcache
func NewMongoDBProcessor ¶ added in v1.10.0
func NewMongoDBProcessor() Processor
func NewMySQLProcessor ¶ added in v1.10.0
func NewMySQLProcessor() Processor
NewMySQLProcessor creates a new processor for MySQL
func NewNatsProcessor ¶ added in v1.10.0
func NewNatsProcessor() Processor
NewNatsProcessor creates a new processor for NATS
func NewPostgresProcessor ¶ added in v1.10.0
func NewPostgresProcessor() Processor
NewPostgresProcessor creates a new processor for PostgreSQL
func NewRabbitMQProcessor ¶ added in v1.10.0
func NewRabbitMQProcessor() Processor
NewRabbitMQProcessor creates a new processor for RabbitMQ
func NewRedisProcessor ¶ added in v1.10.0
func NewRedisProcessor() Processor
NewRedisProcessor creates a new processor for Redis
type ProcessorOption ¶ added in v1.10.0
type ProcessorOption func(*DefaultProcessor)
ProcessorOption is a function that configures a DefaultProcessor
func WithComposeEnv ¶ added in v1.10.0
func WithComposeEnv(fn func(cfg *config.ProjectConfig) string) ProcessorOption
WithComposeEnv sets the compose env code
func WithConfigEnv ¶ added in v1.10.0
func WithConfigEnv(code string) ProcessorOption
WithConfigEnv sets the config env code
func WithConfigField ¶ added in v1.10.0
func WithConfigField(code string) ProcessorOption
WithConfigField sets the config field code
func WithConfigFieldName ¶ added in v1.10.0
func WithConfigFieldName(code string) ProcessorOption
WithConfigFieldName sets the config field name code
func WithFillStructField ¶ added in v1.10.0
func WithFillStructField(code string) ProcessorOption
WithFillStructField sets the fill struct field code
func WithImport ¶ added in v1.10.0
func WithImport(fn func(cfg *config.ProjectConfig) string) ProcessorOption
WithImport sets the import code
func WithMigrateFileData ¶ added in v1.10.0
func WithMigrateFileData(data []byte) ProcessorOption
WithMigrateFileData sets the migrate file data
func WithStructField ¶ added in v1.10.0
func WithStructField(code string) ProcessorOption
WithStructField sets the struct field code
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the available components
func NewRegistry ¶ added in v1.3.1
func NewRegistry(opts ...RegistryOption) *Registry
NewRegistry creates a new Registry with the given options
func (*Registry) GetDB ¶ added in v1.3.1
func (r *Registry) GetDB(code string) ComponentInfo
GetDB returns information about a database component
func (*Registry) GetInfra ¶ added in v1.3.1
func (r *Registry) GetInfra(code string) ComponentInfo
GetInfra returns information about an infrastructure component
func (*Registry) ListDBs ¶ added in v1.3.1
func (r *Registry) ListDBs() []*ComponentInfo
ListDBs returns a sorted list of database components
func (*Registry) ListInfras ¶ added in v1.3.1
func (r *Registry) ListInfras() []*ComponentInfo
ListInfras returns a sorted list of infrastructure components
func (*Registry) RegisterComponent ¶ added in v1.10.0
func (r *Registry) RegisterComponent(info ComponentInfo)
RegisterComponent registers a component with the registry
func (*Registry) RegisterDB ¶ added in v1.10.0
RegisterDB registers a database component
func (*Registry) RegisterInfra ¶ added in v1.10.0
RegisterInfra registers an infrastructure component
func (*Registry) UpdateConfig ¶ added in v1.3.1
func (r *Registry) UpdateConfig(cfg *config.ProjectConfig)
UpdateConfig updates the configuration for all components
type RegistryOption ¶ added in v1.10.0
type RegistryOption func(*Registry)
RegistryOption is a function that configures a Registry
func WithAerospike ¶ added in v1.10.0
func WithAerospike() RegistryOption
WithAerospike returns a registry option that adds Aerospike support
func WithComponent ¶ added in v1.10.0
func WithComponent(info ComponentInfo) RegistryOption
WithComponent adds a component to the registry
func WithDB ¶ added in v1.10.0
func WithDB(code, title string, processor Processor, order int) RegistryOption
WithDB is a convenience function for adding a database component
func WithElasticsearch ¶ added in v1.10.0
func WithElasticsearch() RegistryOption
WithElasticsearch returns a registry option that adds Elasticsearch support
func WithEtcd ¶ added in v1.10.0
func WithEtcd() RegistryOption
WithEtcd returns a registry option that adds Etcd support
func WithInfra ¶ added in v1.10.0
func WithInfra(code, title string, processor Processor, order int) RegistryOption
WithInfra is a convenience function for adding an infrastructure component
func WithKafka ¶ added in v1.3.1
func WithKafka() RegistryOption
WithKafka returns a registry option that adds Kafka support
func WithMemcache ¶ added in v1.10.0
func WithMemcache() RegistryOption
WithMemcache returns a registry option that adds Memcache support
func WithMongo ¶ added in v1.3.1
func WithMongo() RegistryOption
WithMongo returns a registry option that adds MongoDB support
func WithMySQL ¶ added in v1.3.1
func WithMySQL() RegistryOption
WithMySQL returns a registry option that adds MySQL support
func WithNats ¶ added in v1.10.0
func WithNats() RegistryOption
WithNats returns a registry option that adds NATS support
func WithPostgres ¶ added in v1.3.1
func WithPostgres() RegistryOption
WithPostgres returns a registry option that adds PostgreSQL support
func WithRabbitMQ ¶ added in v1.10.0
func WithRabbitMQ() RegistryOption
WithRabbitMQ returns a registry option that adds RabbitMQ support
func WithRedis ¶ added in v1.3.1
func WithRedis() RegistryOption
WithRedis returns a registry option that adds Redis support