container

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 7 Imported by: 0

README

container

Table of contents

Summary

A simple service container.

Architecture

Dependencies

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Option) (*DefaultContainer, ShutdownFunc)

New factory function.

Types

type Container

type Container interface {
	Get(key string) any
	Set(key string, service any, ss func(service any))
	Keys() []string
}

Container container service.

type DefaultContainer

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

DefaultContainer is a service container structure.

func (*DefaultContainer) Get

func (c *DefaultContainer) Get(key string) any

Get method to get the service.

func (*DefaultContainer) Keys

func (c *DefaultContainer) Keys() []string

Keys list all service keys.

func (*DefaultContainer) Set

func (c *DefaultContainer) Set(key string, service any, ss func(service any))

Set method to set the service in the container.

type LogFunc

type LogFunc func(message string)

LogFunc to allow log warnings and infos.

type Option

type Option func(p *DefaultContainer)

Option to be used to build with optional deps.

func WithInfoFunc

func WithInfoFunc(function LogFunc) Option

WithInfoFunc configuration option.

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

WithShutdownTimeout configuration option.

func WithWarnFunc

func WithWarnFunc(function LogFunc) Option

WithWarnFunc configuration option.

type ServiceRecord

type ServiceRecord struct {
	Service  any
	Shutdown func(service any)
}

ServiceRecord service record structure.

type ShutdownFunc

type ShutdownFunc func()

ShutdownFunc shutdown function.

Jump to

Keyboard shortcuts

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