test

package
v0.0.0-...-1e513c5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircularDependencyError

type CircularDependencyError struct {
	ServiceType     string
	ServiceName     string
	DependencyGraph []string
}

CircularDependencyError is returned when there is a circular dependency between two services.

func (CircularDependencyError) Error

func (e CircularDependencyError) Error() string

type NamedServiceFactory

type NamedServiceFactory[T any] func(string, ServiceLocator) (T, error)

NamedServiceFactory creates a new named instance of T.

type ServiceA

type ServiceA interface {
	Foo()
}

ServiceA is an example for service locator tests.

type ServiceB

type ServiceB interface {
	Bar()
}

ServiceB is an example for service locator tests.

type ServiceFactory

type ServiceFactory[T any] func(ServiceLocator) (T, error)

ServiceFactory creates a new instance of T.

type ServiceLocator

type ServiceLocator interface {
	GetServiceA() (ServiceA, error)
	GetServiceB(name string) (ServiceB, error)
	GetServiceC() (subtest.ServiceC, error)
}

ServiceLocator locates named services in a type-safe manner.

type ServiceRegistry

type ServiceRegistry struct {
	// contains filtered or unexported fields
}

ServiceRegistry allows registering service factories to construct new instances of a service. ServiceRegistry is also the primary {ServiceLocator} entrypoint.

func NewServiceRegistry

func NewServiceRegistry() *ServiceRegistry

NewServiceRegistry instantiates a new {ServiceRegistry}.

func (*ServiceRegistry) GetServiceA

func (r *ServiceRegistry) GetServiceA() (ServiceA, error)

GetServiceA retrieves an instance of {ServiceA}.

func (*ServiceRegistry) GetServiceB

func (r *ServiceRegistry) GetServiceB(serviceName string) (ServiceB, error)

GetServiceB retrieves an instance of {ServiceB}.

func (*ServiceRegistry) GetServiceC

func (r *ServiceRegistry) GetServiceC() (subtest.ServiceC, error)

GetServiceC retrieves an instance of {ServiceC}.

func (*ServiceRegistry) RegisterServiceA

func (r *ServiceRegistry) RegisterServiceA(factory ServiceFactory[ServiceA])

RegisterServiceA registers a factory for {ServiceA}.

func (*ServiceRegistry) RegisterServiceB

func (r *ServiceRegistry) RegisterServiceB(serviceName string, factory NamedServiceFactory[ServiceB])

RegisterServiceB registers a factory for {ServiceB}.

func (*ServiceRegistry) RegisterServiceC

func (r *ServiceRegistry) RegisterServiceC(factory ServiceFactory[subtest.ServiceC])

RegisterServiceC registers a factory for {ServiceC}.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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