arrower – github.com/go-arrower/arrower Index | Files | Directories

package arrower

import "github.com/go-arrower/arrower"

Index

Variables

var ErrMissingDependency = errors.New("missing dependency")

Types

type Config

type Config struct {
	OrganisationName string `mapstructure:"organisation_name"`
	ApplicationName  string `mapstructure:"application_name"`
	InstanceName     string `mapstructure:"instance_name"`

	Environment Environment `mapstructure:"environment"`

	HTTP     HTTP     `mapstructure:"http"`
	Postgres Postgres `mapstructure:"postgres"`
	OTEL     OTEL     `mapstructure:"otel"`
}

Config is a structure used for service configuration. It is intended to be mapped by viper.

type Container

type Container struct {
	Logger        alog.Logger
	MeterProvider *metric.MeterProvider
	TraceProvider *trace.TracerProvider

	Config *Config
	PGx    *pgxpool.Pool

	WebRouter   *echo.Echo
	APIRouter   *echo.Group
	AdminRouter *echo.Group
	WebRenderer *renderer.EchoRenderer

	RootCmd *cobra.Command

	ArrowerQueue jobs.Queue
	DefaultQueue jobs.Queue

	Settings setting.Settings

	// auth & admin Contexts
	AuthContext auth.API
	// contains filtered or unexported fields
}

Container holds global dependencies that can be used within each Context, to make initialisation easier. If the Context can operate with the shared resources. Otherwise, the Context is advised to initialise its own dependencies from its own configuration.

func InitialiseDefaultDependencies

func InitialiseDefaultDependencies(ctx context.Context, conf *Config, migrations fs.FS, publicAssets fs.FS, sharedViews fs.FS) (*Container, error)

func New

func New() (*Container, error)

func (*Container) EnsureAllDependenciesPresent

func (c *Container) EnsureAllDependenciesPresent() error

func (*Container) Shutdown

func (c *Container) Shutdown(ctx context.Context) error

func (*Container) Start

func (c *Container) Start(ctx context.Context) error

type CustomValidator

type CustomValidator struct {
	// contains filtered or unexported fields
}

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i interface{}) error

type Environment

type Environment string
const (
	LocalEnv       Environment = "local"
	TestEnv        Environment = "test"
	DevelopmentEnv Environment = "dev"
	ProductionEnv  Environment = "prod"
)

func Environments

func Environments() []Environment

Environments is the list of all supported environments.

type HTTP

type HTTP struct {
	Port                  int           `mapstructure:"port"                    json:"port"`
	CookieSecret          secret.Secret `mapstructure:"cookie_secret,squash"    json:"-"`
	StatusEndpointEnabled bool          `mapstructure:"status_endpoint_enabled" json:"-"`
	StatusEndpointPort    int           `mapstructure:"status_endpoint_port"    json:"-"`
}

type OTEL

type OTEL struct {
	Host     string `mapstructure:"host"     json:"host"`
	Port     int    `mapstructure:"port"     json:"port"`
	Hostname string `mapstructure:"hostname" json:"hostname"`
}

type Postgres

type Postgres struct {
	User     string        `mapstructure:"user"            json:"user"`
	Password secret.Secret `mapstructure:"password,squash" json:"-"`
	Database string        `mapstructure:"database"        json:"database"`
	Host     string        `mapstructure:"host"            json:"host"`
	Port     int           `mapstructure:"port"            json:"port"`
	SSLMode  string        `mapstructure:"ssl_mode"        json:"sslMode"`
	MaxConns int           `mapstructure:"max_conns"       json:"maxConns"`
}

type Viper

type Viper struct {
	*viper.Viper
}

Viper is a wrapper around viper.Viper for configuration loading. The only purpose is to overwrite the Unmarshal method, so that secret.Secret data type is automatically marshalled and the developer does not have to think about it when using DefaultViper.

func DefaultViper

func DefaultViper() *Viper

DefaultViper returns a new viper instance with all default values from Config set.

func (*Viper) Unmarshal

func (vip *Viper) Unmarshal(rawVal any, opts ...viper.DecoderConfigOption) error

Source Files

config.go dependencies.go status.go

Directories

PathSynopsis
aassertPackage aassert provides a set of testing tools for use with the normal Go testing system.
alogPackage alog provides a logger that is a subset of the slog.Logger interface.
alog/models
appPackage app provides common decorators for use cases in the application layer.
arrower
arrower/cmd
arrower/hooksPackage hooks enables you to customise and extend the behaviour of arrower run.
arrower/internal
cmd
contexts
contexts/adminPackage admin is the context's intraprocess API.
contexts/admin/initPackage init is the context's startup API.
contexts/admin/internal
contexts/authPackage auth is the intraprocess API of what this Context is exposing to other Contexts to use.
contexts/auth/init
contexts/auth/internal
ctx
example
example/shared
example/shared/views
jobsPackage jobs provides an easy way to run workloads in the background.
jobs/models
postgres
postgres/models
rendererPackage renderer provides renderers for web views and unit tests.
repositoryPackage repository implements generic repositories.
secretPackage secret contains secrets to use in the application.
setting
setting/models
testsPackage tests contains helpers, that enable you to perform integration tests against a real external service, e.g.
Version
v0.0.0-20250311203644-ab26c1152cb4 (latest)
Published
Mar 11, 2025
Platform
linux/amd64
Imports
41 packages
Last checked
1 week ago

Tools for package owners.