environments

package
v0.0.0-...-2917517 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestingEnv     string = "testing"
	DevelopmentEnv string = "development"
	ProductionEnv  string = "production"

	EnvironmentStringKey string = "OCM_ENV"
	EnvironmentDefault   string = DevelopmentEnv
)

Variables

This section is empty.

Functions

func GetEnvironmentStrFromEnv

func GetEnvironmentStrFromEnv() string

Types

type ApplicationConfig

type ApplicationConfig struct {
	ApplicationConfig *config.ApplicationConfig
}

func (*ApplicationConfig) Accept

func (c *ApplicationConfig) Accept(v ConfigVisitor) error

type ClientVisitable

type ClientVisitable interface {
	Accept(v ClientVisitor) error
}

type ClientVisitor

type ClientVisitor interface {
	VisitClients(c *Clients) error
}

type Clients

type Clients struct {
	OCM *ocm.Client
}

func (*Clients) Accept

func (c *Clients) Accept(v ClientVisitor) error

type ConfigDefaults

type ConfigDefaults struct {
	Server   map[string]interface{}
	Metrics  map[string]interface{}
	Database map[string]interface{}
	OCM      map[string]interface{}
	Options  map[string]interface{}
}

type ConfigVisitable

type ConfigVisitable interface {
	Accept(v ConfigVisitor) error
}

type ConfigVisitor

type ConfigVisitor interface {
	VisitConfig(c *ApplicationConfig) error
}

type Database

type Database struct {
	SessionFactory db.SessionFactory
}

func (*Database) Accept

func (d *Database) Accept(v DatabaseVisitor) error

type DatabaseVisitable

type DatabaseVisitable interface {
	Accept(v DatabaseVisitor) error
}

type DatabaseVisitor

type DatabaseVisitor interface {
	VisitDatabase(s *Database) error
}

type DinosaurServiceLocator

type DinosaurServiceLocator func() services.DinosaurService

func NewDinosaurServiceLocator

func NewDinosaurServiceLocator(env *Env) DinosaurServiceLocator

type Env

type Env struct {
	Name     string
	Services Services
	Handlers Handlers
	Clients  Clients
	Database Database
	// packaging requires this construct for visiting
	ApplicationConfig ApplicationConfig
	// most code relies on env.Config
	Config *config.ApplicationConfig
}

func Environment

func Environment() *Env

func (*Env) AddFlags

func (e *Env) AddFlags(flags *pflag.FlagSet) error

Adds environment flags, using the environment's config struct, to the flagset 'flags'

func (*Env) Initialize

func (e *Env) Initialize() error

Initialize loads the environment's resources This should be called after the e.Config has been set appropriately though AddFlags and pasing, done elsewhere The environment does NOT handle flag parsing

func (*Env) InitializeSentry

func (e *Env) InitializeSentry() error

func (*Env) LoadClients

func (e *Env) LoadClients() error

func (*Env) LoadServices

func (e *Env) LoadServices()

func (*Env) Seed

func (e *Env) Seed() *errors.ServiceError

func (*Env) Teardown

func (e *Env) Teardown()

type EnvironmentImpl

type EnvironmentImpl interface {
	Flags() map[string]string
	VisitConfig(c *ApplicationConfig) error
	VisitDatabase(s *Database) error
	VisitServices(s *Services) error
	VisitHandlers(c *Handlers) error
	VisitClients(c *Clients) error
}

EnvironmentImpl defines a set of behaviors for an OCM environment. Each environment provides a set of flags for basic set/override of the environment. Each environment is a set of configured things (services, handlers, clients, etc.) and we may expect a stable set of components. Use Visitor pattern to allow external callers (an environment) to affect the internal structure of components. Each visitor is applied after a component is instantiated with flags set. VisitorConfig is applies after instantiation but before ReadFiles is called.

type EventServiceLocator

type EventServiceLocator func() services.EventService

func NewEventServiceLocator

func NewEventServiceLocator(env *Env) EventServiceLocator

type GenericServiceLocator

type GenericServiceLocator func() services.GenericService

func NewGenericServiceLocator

func NewGenericServiceLocator(env *Env) GenericServiceLocator

type HandlerVisitable

type HandlerVisitable interface {
	Accept(v HandlerVisitor) error
}

type HandlerVisitor

type HandlerVisitor interface {
	VisitHandlers(c *Handlers) error
}

type Handlers

type Handlers struct {
	AuthMiddleware auth.JWTMiddleware
}

func (*Handlers) Accept

func (c *Handlers) Accept(v HandlerVisitor) error

type ServiceVisitable

type ServiceVisitable interface {
	Accept(v ServiceVisitor) error
}

type ServiceVisitor

type ServiceVisitor interface {
	VisitServices(s *Services) error
}

type Services

type Services struct {
	Dinosaurs DinosaurServiceLocator
	Generic   GenericServiceLocator
	Events    EventServiceLocator
}

func (*Services) Accept

func (s *Services) Accept(v ServiceVisitor) error

Jump to

Keyboard shortcuts

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