loader

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendService

func AppendService(serviceType service.ServiceType, fn ServiceFn) bool

func Exists

func Exists(services ...service.ServiceType) (map[service.ServiceType]bool, bool)

Exists checks if services exist in the registry. It returns a map containing the services that do not exist in the registry and a boolean indicating if all services exist.

func Get

func Get(name service.ServiceType) (service.Service, bool)

Get retrieves the internal information of a specific registered service based on its name. It returns the internal information of the registered service, or nil if the service does not exist.

func List

func List() []service.Service

List retrieves a list of all registered services.

func LoadDependencies

func LoadDependencies(ctx *cli.Context, baseService *service.BaseService) error

LoadDependencies loads dependencies for registered services into the base service.

It iterates through the registered services and their dependencies, registers each dependency into the base service, and returns an error if any dependency registration fails.

func New

func New(ctx *cli.Context) (service.Service, error)

New creates a new service based on the provided context.

It retrieves the requested services from the context and validates their existence. Then, it creates a new base service with the requested services and registers built-in loader services. After that, it loads dependencies for the base service and returns the created base service. It returns an error if any step fails during the process.

func Register

func Register(name service.ServiceType, srvc service.Service) bool

Register adds a service to the registry if it doesn't already exist. It returns true if the service was successfully registered, false otherwise.

func RegisterServices

func RegisterServices(ctx *cli.Context, baseService service.Service) error

RegisterServices registers built-in services including attached services with the provided context and base service. It returns an error if any of the built-in services fail to register.

func Remove

func Remove(serviceType service.ServiceType)

Remove removes a service from the registry.

func Run

func Run(ctx *cli.Context, srvc service.Service) error

Run executes the provided service based on the provided context.

It retrieves the network configuration from the context, starts the service with the provided network, and returns any error encountered during execution.

Types

type ServiceFn

type ServiceFn func(ctx *cli.Context, baseService service.Service) (service.Service, error)

Jump to

Keyboard shortcuts

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