Documentation
¶
Index ¶
- func ConvertToEntityTarget(target Target) entity.Target
- func ConvertToEntityTask(task Task) entity.Task
- func GetTarget(targetName string, config map[string]interface{}) (entity.Target, error)
- func GetTask(taskName string, config map[string]interface{}) (entity.Task, error)
- func RegisterTargetType(name string, targetConstructor TargetConstructor)
- func RegisterTaskType(name string, taskConstructor TaskConstructor)
- type Application
- type Hub
- type LogLevel
- type Option
- type RegisteredTargets
- type ServiceRequest
- type ServiceResponse
- type Target
- type TargetAdapter
- type TargetConstructor
- type TargetConstructorFunc
- type Task
- type TaskAdapter
- type TaskConstructor
- type TaskConstructorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToEntityTarget ¶
ConvertToEntityTarget converts api.Target to entity.Target
func ConvertToEntityTask ¶
ConvertToEntityTask converts api.Task to entity.Task
func RegisterTargetType ¶
func RegisterTargetType(name string, targetConstructor TargetConstructor)
func RegisterTaskType ¶
func RegisterTaskType(name string, taskConstructor TaskConstructor)
Types ¶
type Application ¶
type Application struct {
ApplicationName string
ApplicationHome string
PrivatePort int
PublicPort int
CustomTaskTypes []entity.TaskConstructor
CustomTargets []entity.TargetConstructor
LogLevel LogLevel
Hub Hub
PublicHandler *requesthandler.RequestHandler
PrivateHandler *requesthandler.RequestHandler
Logger *zerolog.Logger
}
func NewApplication ¶
func NewApplication(applicationName string, opts ...Option) *Application
func (*Application) Start ¶
func (a *Application) Start() error
func (*Application) Stop ¶
func (a *Application) Stop() error
type LogLevel ¶
type LogLevel int
func (LogLevel) ToZeroLogLevel ¶
ToZeroLogLevel converts LogLevel to zerolog.Level
type Option ¶
type Option func(*Application)
func WithApplicationHome ¶
func WithCustomTargets ¶
func WithCustomTargets(targets ...entity.TargetConstructor) Option
func WithCustomTasks ¶
func WithCustomTasks(targets ...entity.TaskConstructor) Option
func WithLogLevel ¶
func WithPrivatePort ¶
func WithPublicPort ¶
type RegisteredTargets ¶
type RegisteredTargets map[string]TargetConstructor
RegisteredTargets allows us to register targets at start-up
type ServiceRequest ¶
type ServiceRequest entity.ServiceRequest
type ServiceResponse ¶
type ServiceResponse entity.ServiceResponse
type Target ¶
type Target interface {
Apply(ctx context.Context, request ServiceRequest) (ServiceResponse, error)
}
We duplicate the Target interface from the entity package to allow for the evolution of the API without breaking changes.
type TargetAdapter ¶
type TargetAdapter struct {
// contains filtered or unexported fields
}
TargetAdapter wraps an api.Target and implements entity.Target
func NewTargetAdapter ¶
func NewTargetAdapter(target Target) *TargetAdapter
NewTargetAdapter creates a new TargetAdapter
func (*TargetAdapter) Apply ¶
func (a *TargetAdapter) Apply(ctx context.Context, request entity.ServiceRequest) (entity.ServiceResponse, error)
Apply implements entity.Target
type TargetConstructor ¶
TargetConstructor takes a config object and returns a configured Target instance.
type TargetConstructorFunc ¶
TaskConstructorFunc is a function type that implements TaskConstructor
func TargetConstructorFromFunction ¶
func TargetConstructorFromFunction( fn func(map[string]interface{}) (Target, error), ) TargetConstructorFunc
TargetConstructorFromFunction creates a TargetConstructorFunc from a function with the signature func(map[string]interface{}) (T, error), where T implements Target
type Task ¶
type Task interface {
Name() string
Apply(ctx context.Context, request ServiceRequest) error
}
We duplicate the Task interface from the entity package to allow for the evolution of the API without breaking changes.
type TaskAdapter ¶
type TaskAdapter struct {
// contains filtered or unexported fields
}
TaskAdapter wraps an api.Task and implements entity.Task
func NewTaskAdapter ¶
func NewTaskAdapter(task Task) *TaskAdapter
NewTaskAdapter creates a new TaskAdapter
func (*TaskAdapter) Apply ¶
func (a *TaskAdapter) Apply(ctx context.Context, request entity.ServiceRequest) error
Apply implements entity.Task
type TaskConstructorFunc ¶
TaskConstructorFunc is a function type that implements TaskConstructor
func TaskConstructorFromFunction ¶
func TaskConstructorFromFunction( fn func(map[string]interface{}) (Task, error), ) TaskConstructorFunc
TaskConstructorFromFunction creates a TaskConstructorFunc from a function with the signature func(map[string]interface{}) (T, error), where T implements Task