service

package
v0.21.6 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDefaultNotNullFields added in v0.21.0

func WithDefaultNotNullFields(o *Options)

DefaultNotNullFields sets the non-pointer model fields to not null by default. By default all fields are set as nullable in the model's definition. WithThis might be helpful in the model migration.

Types

type Closer added in v0.21.0

type Closer interface {
	Close(ctx context.Context) error
}

Closer is an interface that closes all connection for given instance.

type Dialer added in v0.21.0

type Dialer interface {
	Dial(ctx context.Context) error
}

Dialer is an interface that starts the connection for the store.

type Option

type Option func(o *Options)

Option is the function that sets the options for the service.

func WithAuthenticator added in v0.21.0

func WithAuthenticator(authenticator auth.Authenticator) Option

WithAuthenticator sets the authenticator option.

func WithDefaultFileStore added in v0.21.0

func WithDefaultFileStore(s filestore.Store) Option

WithDefaultFileStore sets the default file store for the service.

func WithDefaultRepository added in v0.21.0

func WithDefaultRepository(r repository.Repository) Option

WithDefaultRepository sets the default repository for all models without specified repository.

func WithDefaultStore added in v0.21.0

func WithDefaultStore(s store.Store) Option

WithDefaultStore sets the default store for the service.

func WithFileStore added in v0.21.0

func WithFileStore(name string, s filestore.Store) Option

WithFileStore sets the service store 's' obtainable at 'name'.

func WithHandleSignal added in v0.21.0

func WithHandleSignal(handle bool) Option

WithHandleSignal is the option that determines if the os signals should be handled by the service.

func WithMigrateModels added in v0.21.0

func WithMigrateModels(models ...mapping.Model) Option

WithMigrateModels is the option that sets the models to migrate in their repositories.

func WithModels added in v0.21.0

func WithModels(models ...mapping.Model) Option

WithModels is the option that sets the models for given service.

func WithNamingConvention added in v0.21.0

func WithNamingConvention(convention mapping.NamingConvention) Option

WithNamingConvention sets the naming convention option.

func WithRepositoryModels added in v0.21.0

func WithRepositoryModels(r repository.Repository, models ...mapping.Model) Option

WithRepositoryModels maps the repository 'r' to provided 'models'.

func WithServer added in v0.21.0

func WithServer(s server.Server) Option

WithServer sets the service server option.

func WithStore added in v0.21.0

func WithStore(name string, s store.Store) Option

WithStore sets the service store 's' obtainable at 'name'.

func WithSynchronousConnections added in v0.21.0

func WithSynchronousConnections(sync bool) Option

WithSynchronousConnections defines if the service should query repositories synchronously.

func WithTimeFunc added in v0.21.0

func WithTimeFunc(timeFunc func() time.Time) Option

WithTimeFunc sets the time function for the service.

func WithTokener added in v0.21.0

func WithTokener(tokener auth.Tokener) Option

WithTokener sets provided tokener for the service options.

func WithVerifier added in v0.21.0

func WithVerifier(authorizer auth.Verifier) Option

WithVerifier sets the authorization verifier for the service.

type Options

type Options struct {
	// Database Layer
	MigrateModels          []mapping.Model
	DefaultRepository      repository.Repository
	RepositoryModels       map[repository.Repository][]mapping.Model
	SynchronousConnections bool

	// Key-value stores.
	DefaultStore store.Store
	Stores       map[string]store.Store

	// File stores.
	DefaultFileStore filestore.Store
	FileStores       map[string]filestore.Store

	// Model options.
	NamingConvention mapping.NamingConvention
	Models           []mapping.Model
	DefaultNotNull   bool

	// Service server.
	Server server.Server

	// Auth abstractions.
	Verifier      auth.Verifier
	Authenticator auth.Authenticator
	Tokener       auth.Tokener

	// Service detailed options.
	HandleSignals bool
	// TimeFunc sets the time function for the service.
	TimeFunc func() time.Time
}

Options is the structure that contains service options.

type Service

type Service struct {
	Options *Options

	// ModelMap is a mapping for the model's structures.
	ModelMap *mapping.ModelMap
	// DB contains the databases connection.
	DB database.DB

	// Stores is the mapping of the stores with their names.
	Stores map[string]store.Store
	// DefaultStore is the default key-value store used by this controller.
	DefaultStore store.Store

	// Authenticator is the service authenticator.
	Authenticator auth.Authenticator
	// Tokener is the service authentication token creator.
	Tokener auth.Tokener
	// Verifier is the authorization verifier.
	Verifier auth.Verifier

	// FileStores is the mapping of the stores with their names.
	FileStores map[string]filestore.Store
	// DefaultFileStore is the default file store used by this controller.
	DefaultFileStore filestore.Store
	// Server serves defined models.
	Server server.Server
}

Service is the neuron service struct definition.

func New

func New(options ...Option) (*Service, error)

New creates new service for provided controller config.

func (*Service) Close added in v0.21.0

func (s *Service) Close(ctx context.Context) error

Close closes all connection within provided context.

func (*Service) Dial added in v0.21.0

func (s *Service) Dial(ctx context.Context) error

Dial establish connection for all dialers in the service.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run starts the service and it's server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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