service

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstructorFn added in v0.4.1

type ConstructorFn func() interface{}

Constructor function for creating new service records.

type Service

type Service struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Service structure.

To use:

1) Invoke `service.GetInstance` to access the singleton:

```go

svc := service.GetInstance

```

2a) Add your required service:

```go

svc.Add("SomeName", someInstance)

```

2b) Create your required service:

```go

svc.Create("SomeName", func() interface{} { return NewThing() })

```

Profit.

func DumpInstance

func DumpInstance() *Service

Debugging aid -- do *not* use.

func GetInstance

func GetInstance() *Service

Return the service manager's singleton instance.

func (*Service) Add

func (s *Service) Add(name string, thing interface{})

Add a new service instance with the given name.

func (*Service) AddClass

func (s *Service) AddClass(name string, ctor ConstructorFn)

Add a new class with the given name.

func (*Service) Classes

func (s *Service) Classes() []string

Get a list of registered classes.

func (*Service) CountClasses

func (s *Service) CountClasses() int

Return a count of registered classes.

func (*Service) CountServices

func (s *Service) CountServices() int

Return a count of registered services.

func (*Service) CreateNew

func (s *Service) CreateNew(name string) (interface{}, bool)

Create a new instance of the given class by invoking its registered constructor.

func (*Service) Get

func (s *Service) Get(name string) (interface{}, bool)

Get a service with the given name.

func (*Service) Services

func (s *Service) Services() []string

Get a list of registered services.

Jump to

Keyboard shortcuts

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