onion

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: MIT Imports: 7 Imported by: 0

README

onion

var app = onion.New(
    context.Background(),
    onion.WithLogger(log),
    onion.WithContainer(di.NewContainer()),
    onion.WithProviders(cfg),
    onion.WithLayers(infrastructure.New(), domain.New(), application.New(), www.New()),
)

if err = app.Listen(); err != nil {
    log.Error().Err(err).Send()
    os.Exit(1)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	Listen() error
}

Application interface

func New

func New(ctx context.Context, options ...Option) Application

New creates new application

type Layer

type Layer interface {
	Initialize(context.Context) error
}

Layer is an Application layer abstraction

type Option

type Option func(Options)

Option represents single option type

func WithContainer

func WithContainer(container di.Container) Option

WithContainer creates a container Option

func WithLayers

func WithLayers(layers ...Layer) Option

WithLayers creates a layers Option

func WithLogger

func WithLogger(log zerolog.Logger) Option

WithLogger creates a logger Option

func WithProviders

func WithProviders(providers ...di.Provider) Option

WithProviders creates a providers Option

type Options

type Options interface {
	SetContainer(di.Container)
	SetLogger(zerolog.Logger)
	SetProviders(...di.Provider)
	SetLayers(...Layer)
}

Options represents a target for applying an Option

type Shutdowner added in v1.0.2

type Shutdowner interface {
	Shutdown() <-chan error
}

Shutdowner is a layer that has his state shutdown logic

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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