builder

package
v0.0.0-...-75be81d Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildEventBroker

func BuildEventBroker(ctx context.Context, logger *slog.Logger, cfg EventsBrokerConfig) (core.Broker, error)

func BuildEvents

func BuildEvents(ctx context.Context, logger *slog.Logger, config EventsConfig) (core.Broker, error)

func BuildPrettySlogHandler

func BuildPrettySlogHandler(w io.Writer, level slog.Level) slog.Handler

func BuildResources

func BuildResources(ctx context.Context, broker core.Broker, logger *slog.Logger, config ResourcesConfig) (core.ResourceDB, error)

func BuildResourcesObserver

func BuildResourcesObserver(ctx context.Context, broker core.Broker, logger *slog.Logger, config ResourcesObserverConfig) (resources.Observer, error)

func BuildResourcesStorage

func BuildResourcesStorage(ctx context.Context, config ResourcesStorageConfig) (core.ResourceDB, error)

func BuildServiceCore

func BuildServiceCore(ctx context.Context, defaultName string, logger *slog.Logger, config ServiceConfig) (service.Core, error)

func BuildServiceLogger

func BuildServiceLogger(
	handler slog.Handler,
	service string,
) *slog.Logger

func BuildSystem

func BuildSystem(ctx context.Context, logger *slog.Logger, config SystemConfig) (*core.System, error)

func BuildTasks

func BuildTasks(ctx context.Context, logger *slog.Logger, config TasksConfig) (core.TaskDB, error)

func BuildTasksStorage

func BuildTasksStorage(ctx context.Context, logger *slog.Logger, config TasksStorageConfig) (core.TaskDB, error)

func ParseEnvVariableHookFunc

func ParseEnvVariableHookFunc() mapstructure.DecodeHookFunc

func ToDurationHookFunc

func ToDurationHookFunc() mapstructure.DecodeHookFunc

Types

type Config

type Config struct {
	Core     CoreConfig     `yaml:"core,omitempty" json:"core,omitempty"`
	Services ServicesConfig `yaml:"services,omitempty" json:"services,omitempty"`
}

func FromFile

func FromFile(path string) (config Config, err error)

type CoreConfig

type CoreConfig struct {
	System         SystemConfig         `yaml:"system,omitempty" json:"system,omitempty"`
	Specifications SpecificationsConfig `yaml:"specifications,omitempty" json:"specifications,omitempty"`
}

type Deployment

type Deployment[S service.Service] struct {
	Service     S
	Middlewares []service.Middleware
}

func BuildDiscoveryDeployment

func BuildDiscoveryDeployment(ctx context.Context, sys *core.System, logger *slog.Logger, cfg DiscoveryServiceConfig) (Deployment[*discovery.Poller], error)

func BuildHttpApiDeployment

func BuildHttpApiDeployment(ctx context.Context, sys *core.System, specificationManager *specification.Manager, logger *slog.Logger, cfg HttpApiServiceConfig) (Deployment[*HttpApiService], error)

func BuildProcessorDeployment

func BuildProcessorDeployment(ctx context.Context, sys *core.System, exe executor.Executor, logger *slog.Logger, cfg ProcessorServiceConfig) (Deployment[*executor.Service], error)

func BuildSchedulerDeployment

func BuildSchedulerDeployment(ctx context.Context, sys *core.System, logger *slog.Logger, cfg SchedulerServiceConfig) (Deployment[*dependencies.Service], error)

func BuildStatusDeployment

func BuildStatusDeployment(ctx context.Context, sys *core.System, logger *slog.Logger, cfg StatusServiceConfig) (Deployment[*status.Service], error)

type DiscoveryHubConfig

type DiscoveryHubConfig struct {
	Kind    string         `yaml:"kind,omitempty" json:"kind,omitempty"`
	Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
}

type DiscoveryServiceConfig

type DiscoveryServiceConfig struct {
	ServiceConfig   ServiceConfig      `yaml:"$,omitempty" json:"$,omitempty"`
	PollingInterval time.Duration      `yaml:"polling_interval,omitempty" json:"polling_interval,omitempty"`
	Hub             DiscoveryHubConfig `yaml:"hub,omitempty" json:"hub,omitempty"`
}

type DynamicConfig

type DynamicConfig map[string]any

func (DynamicConfig) Bind

func (config DynamicConfig) Bind(to any) error

func (DynamicConfig) Kind

func (config DynamicConfig) Kind() string

type EventsBrokerConfig

type EventsBrokerConfig struct {
	Kind    string         `yaml:"kind,omitempty" json:"kind,omitempty"`
	URI     string         `yaml:"uri,omitempty" json:"uri,omitempty"`
	Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
}

type EventsConfig

type EventsConfig struct {
	Broker EventsBrokerConfig `yaml:"broker,omitempty" json:"broker,omitempty"`
}

type HttpApiService

type HttpApiService struct {
	service.Core
	// contains filtered or unexported fields
}

func (HttpApiService) Run

func (srvc HttpApiService) Run(ctx context.Context) error

type HttpApiServiceConfig

type HttpApiServiceConfig struct {
	ServiceConfig ServiceConfig `yaml:"$,omitempty" json:"$,omitempty"`
	Port          int           `yaml:"port,omitempty" json:"port,omitempty"`
	LoggerEnabled bool          `yaml:"logger_enabled,omitempty" json:"logger_enabled,omitempty"`
}

type ProcessorServiceConfig

type ProcessorServiceConfig struct {
	ServiceConfig ServiceConfig `yaml:"$,omitempty" json:"$,omitempty"`
	Kind          string        `yaml:"kind,omitempty" json:"kind,omitempty"`
}

type ResourcesConfig

type ResourcesConfig struct {
	Storage   ResourcesStorageConfig    `yaml:"storage,omitempty" json:"storage,omitempty"`
	Observers []ResourcesObserverConfig `yaml:"observers,omitempty" json:"observers,omitempty"`
}

type ResourcesObserverConfig

type ResourcesObserverConfig struct {
	Kind    string        `yaml:"kind,omitempty" json:"kind,omitempty"`
	Options DynamicConfig `yaml:"options,omitempty" json:"options,omitempty"`
}

type ResourcesStorageConfig

type ResourcesStorageConfig struct {
	Kind    string         `yaml:"kind,omitempty" json:"kind,omitempty"`
	URI     string         `yaml:"uri,omitempty" json:"uri,omitempty"`
	Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
}

type SchedulerDependenciesConfig

type SchedulerDependenciesConfig struct {
	Poller struct {
		Interval  time.Duration `yaml:"interval,omitempty" json:"interval,omitempty"`
		BatchSize int           `yaml:"batch_size,omitempty" json:"batch_size,omitempty"`
	} `yaml:"poller,omitempty" json:"poller,omitempty"`
	Postgres struct {
		URI     string         `yaml:"uri,omitempty" json:"uri,omitempty"`
		Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
	} `yaml:"postgres,omitempty" json:"postgres,omitempty"`
}

type SchedulerResolverConfig

type SchedulerResolverConfig struct {
	Kind string        `yaml:"kind,omitempty" json:"kind,omitempty"`
	Data DynamicConfig `yaml:"data,omitempty" json:"data,omitempty"`
}

type SchedulerResourceResolverConfig

type SchedulerResourceResolverConfig struct {
	Storage SchedulerResourceResolverStorageConfig `yaml:"storage,omitempty" json:"storage,omitempty"`
	Poller  struct {
		Limit    int           `yaml:"limit,omitempty" json:"limit,omitempty"`
		Interval time.Duration `yaml:"interval,omitempty" json:"interval,omitempty"`
	} `yaml:"poller,omitempty" json:"poller,omitempty"`
}

type SchedulerResourceResolverStorageConfig

type SchedulerResourceResolverStorageConfig struct {
	Kind    string         `yaml:"kind,omitempty" json:"kind,omitempty"`
	URI     string         `yaml:"uri,omitempty" json:"uri,omitempty"`
	Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
}

type SchedulerServiceConfig

type SchedulerServiceConfig struct {
	ServiceConfig ServiceConfig               `yaml:"$,omitempty" json:"$,omitempty"`
	TaskToGroup   SchedulerTaskToGroupConfig  `yaml:"task_to_group,omitempty" json:"task_to_group,omitempty"`
	Dependencies  SchedulerDependenciesConfig `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
	Resolvers     []SchedulerResolverConfig   `yaml:"resolvers,omitempty" json:"resolvers,omitempty"`
}

type SchedulerTaskToGroupConfig

type SchedulerTaskToGroupConfig struct {
	Kind    string         `yaml:"kind,omitempty" json:"kind,omitempty"`
	URI     string         `yaml:"uri,omitempty" json:"uri,omitempty"`
	Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
}

type ServiceConfig

type ServiceConfig struct {
	ID        string                 `yaml:"id,omitempty" json:"id,omitempty"`
	Name      string                 `yaml:"name,omitempty" json:"name,omitempty"`
	Discovery ServiceDiscoveryConfig `yaml:"discovery,omitempty" json:"discovery,omitempty"`
}

type ServiceDiscoveryConfig

type ServiceDiscoveryConfig struct {
	Enabled bool           `yaml:"enabled,omitempty" json:"enabled,omitempty"`
	Info    map[string]any `yaml:"info,omitempty" json:"info,omitempty"`
}

type ServicesConfig

type ServicesConfig struct {
	HttpApi   HttpApiServiceConfig   `yaml:"http_api,omitempty" json:"http_api,omitempty"`
	Scheduler SchedulerServiceConfig `yaml:"scheduler,omitempty" json:"scheduler,omitempty"`
	Status    StatusServiceConfig    `yaml:"status,omitempty" json:"status,omitempty"`
	Processor ProcessorServiceConfig `yaml:"processor,omitempty" json:"processor,omitempty"`
	Discovery DiscoveryServiceConfig `yaml:"discovery,omitempty" json:"discovery,omitempty"`
}

type SpecificationsConfig

type SpecificationsConfig struct {
	Storage SpecificationsStorageConfig `yaml:"storage,omitempty" json:"storage,omitempty"`
}

type SpecificationsStorageConfig

type SpecificationsStorageConfig struct {
	Kind    string         `yaml:"kind,omitempty" json:"kind,omitempty"`
	URI     string         `yaml:"uri,omitempty" json:"uri,omitempty"`
	Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
}

type StatusServiceConfig

type StatusServiceConfig struct {
	ServiceConfig ServiceConfig `yaml:"$,omitempty" json:"$,omitempty"`
}

type SystemConfig

type SystemConfig struct {
	Tasks     TasksConfig     `yaml:"tasks,omitempty" json:"tasks,omitempty"`
	Resources ResourcesConfig `yaml:"resources,omitempty" json:"resources,omitempty"`
	Events    EventsConfig    `yaml:"events,omitempty" json:"events,omitempty"`
}

type TasksConfig

type TasksConfig struct {
	Storage TasksStorageConfig `yaml:"storage,omitempty" json:"storage,omitempty"`
}

type TasksStorageConfig

type TasksStorageConfig struct {
	Kind    string         `yaml:"kind,omitempty" json:"kind,omitempty"`
	URI     string         `yaml:"uri,omitempty" json:"uri,omitempty"`
	Options map[string]any `yaml:"options,omitempty" json:"options,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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