servlet

package module
v1.3.0 Latest Latest
Warning

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

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

README

Servlet

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application added in v1.3.0

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

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

func NewApplication added in v1.3.0

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
	Add(id string, factory ContainerFactory) error
	Remove(id string)
	Get(id 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 ContainerFactory

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

ContainerFactory 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 servlet application and register elements in the application container and do some necessary boot actions on initialization.

Jump to

Keyboard shortcuts

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