app

package
v0.0.0-...-16952c6 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostgresAppUrlEnvKey = "POSTGRES_APP_URL"
	RepositoryBaseEnvKey = "REPOSITORY_BASE"
	AuthorizationHeader  = "authorization"
	IDHeader             = "x-grokloc-id"
	TokenRequestHeader   = "x-grokloc-token-request" // #nosec G101
	MaxBodySize          = 8192
	APIPath              = "/api/"
)

Variables

View Source
var ErrorBody = fmt.Errorf("body malformed or exceeds %v bytes", MaxBodySize)
View Source
var ErrorEnvVar = errors.New("missing or malformed environment variable")
View Source
var ErrorInadequateAuthorization = errors.New("inadequate authorization provided")

Functions

This section is empty.

Types

type State

type State struct {
	// Level describes the environment the State is set in
	Level env.Level

	// Logger is the default state logger
	Logger *slog.Logger

	// APIVersion is the expected runtime supported api version
	APIVersion string

	// Master is a pool of conns to the master db
	Master *pgxpool.Pool

	// Replicas is a pool of conns to the replica dbs
	Replicas []*pgxpool.Pool

	// ConnTimeout is a timeout to acquire a db conn
	ConnTimeout time.Duration

	// ExecTimeout is a timeout for executing a db query
	ExecTimeout time.Duration

	// Argon2Config for password hashing
	Argon2Config argon2.Config

	// RepositoryBase is the path where checked out repos are found
	RepositoryBase string

	// SigningKey signs JWTs
	SigningKey []byte

	// VersionKey maps key ids to database encryption keys
	VersionKey *security.VersionKey

	// DefaultRole is the environment role default for models instance
	DefaultRole models.Role

	// Root user
	Root *user.User

	// Root org
	Org *org.Org
}

State contains all references and values that must be available for the duration of an app run.

func (*State) Close

func (s *State) Close() error

Close performs any post-use tasks.

func (*State) RandomReplica

func (s *State) RandomReplica() *pgxpool.Pool

RandomReplica selects a random replica.

Directories

Path Synopsis
admin
org
Package org contains package methods for org support.
Package org contains package methods for org support.
user
Package user contains package methods for user support.
Package user contains package methods for user support.
api
handlers/ok
Package ok provides an unauthenticated healthcheck handler.
Package ok provides an unauthenticated healthcheck handler.
package audit provides mutation recording.
package audit provides mutation recording.
git
repository
Package repository contains package methods for git repository support.
Package repository contains package methods for git repository support.
Package jwt provides token functionality.
Package jwt provides token functionality.
Package models provides shared model definitions.
Package models provides shared model definitions.
state
unit
Package unit manages state for the Unit environment.
Package unit manages state for the Unit environment.
Package testing provides test utility functions.
Package testing provides test utility functions.

Jump to

Keyboard shortcuts

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