gapp

package module
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: MIT Imports: 1 Imported by: 12

README

GApp

This library intent to provide a flexible and opinionated structure to build applications in a way that removes the problems of coding the same functionalities over and over regarding system components as configuration or logging.

Is the opinion of the library that the application scaffolding should revolve around the idea of a service container, seen in other types of frameworks. This container is responsible for storing factories of the application services that should be called for service instantiation, per need. This facilitates not only the composition of the application, but also directs the application architecture for a more dependency injection way of structuring services. By following this decoupled way of writing the application. will enable for more scalable and maintainable testing and production code.

Documentation

Index

Constants

View Source
const ContainerID = "gapp"

ContainerID defines the gapp package container entry id base string.

View Source
const Env = "GAPP"

Env defines the gapp package environment entry id base string.

Variables

This section is empty.

Functions

func ErrNilPointer added in v1.6.0

func ErrNilPointer(arg string) error

ErrNilPointer generates a nil pointer argument call error.

func ErrNotFound added in v1.6.0

func ErrNotFound(arg string) error

ErrNotFound generates an entry not found error.

Types

type Application

type Application interface {
	Container() Container
	Add(provider Provider) error
	Boot() error
}

Application interface used to define the methods of a gapp application.

func NewApplication

func NewApplication() Application

NewApplication used to instantiate a new application.

type Closable

type Closable interface {
	Close()
}

Closable is the interface used to signal the container that the element must be closed on removal.

type Container

type Container interface {
	Close()
	Has(id string) bool
	Service(id string, factory Factory, tags ...string) error
	Factory(id string, factory Factory, tags ...string) error
	Remove(id string)
	Get(id string) (interface{}, error)
	Tagged(tag string) ([]interface{}, error)
}

Container is an interface for an object used to lazy load and store instances of registered objects. This is achieved by the registration of factory functions that will instantiate the instances as needed.

func NewContainer

func NewContainer() Container

NewContainer instantiates a new container object.

type Factory added in v1.7.0

type Factory func(Container) (interface{}, error)

Factory is a callback function used to instantiate an object used by the application container when a not yet instantiated object is requested.

type Provider

type Provider interface {
	Register(Container) error
	Boot(Container) error
}

Provider is an interface used to define the methods of an object that can be registered into a gapp application and register elements in the application container and do some necessary boot actions on initialization.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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