api

package
v0.0.0-...-e16bcd7 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptionInitDB

func OptionInitDB(api *API) error

OptionInitDB will initialize the database during the API instance creation, dropping all existing tables, which will force all migration scripts to be re-executed. Use with caution, this will DESTROY ALL YOUR DATA.

func OptionInstanceMode

func OptionInstanceMode(mode config.InstanceMode) func(*API) error

OptionInstanceMode records the node role this process was started with, which selects the serving database role. Without it a node provisions the way a single instance does.

func SetDBPasswordProvider

func SetDBPasswordProvider(provider DBPasswordProvider)

SetDBPasswordProvider installs the provider New authenticates with. Call it before New.

Types

type API

type API struct {
	*dbreads.Queries
	// contains filtered or unexported fields
}

API represents an api instance used to interact with Nebraska entities.

func New

func New(options ...func(*API) error) (*API, error)

New creates a new API instance, creates the underlying db connection.

func NewForTest

func NewForTest(options ...func(*API) error) (*API, error)

NewForTest creates a new API instance with given options and fills the database with sample data for testing purposes.

func NewWithMigrations

func NewWithMigrations(options ...func(*API) error) (*API, error)

NewWithMigrations creates a new API instance, creates the underlying db connection and applies all available db migrations.

func (*API) Close

func (api *API) Close()

Close releases the connections to the database.

func (*API) Conn

func (api *API) Conn() *dbconn.Conn

Conn returns the shared database connection (dbconn.Conn) owned by this API instance.

func (*API) MigrateDown

func (api *API) MigrateDown(version string) (int, error)

func (*API) Reads

func (api *API) Reads() *dbreads.Queries

Reads returns the shared read queries (dbreads.Queries) owned by this API instance.

type DBPasswordProvider

type DBPasswordProvider interface {
	DBPassword(ctx context.Context, user string) (string, error)
}

DBPasswordProvider supplies the password used to authenticate a database connection. Nebraska calls it before opening every physical connection, so an implementation is free to return a credential that expires, such as an OAuth token, without Nebraska having to know how it is obtained.

The user the connection is being made as is passed so that a single provider can serve connections that authenticate as different roles.

If connect_timeout is set in NEBRASKA_DB_URL, the context carries it as its deadline, and an implementation is expected to honour it.

Directories

Path Synopsis
Package admin provides write operations for admin-managed tables (application, channel, package, groups, team, users).
Package admin provides write operations for admin-managed tables (application, channel, package, groups, team, users).
internal
dbconn
Package dbconn owns the database connection shared by the api stack.
Package dbconn owns the database connection shared by the api stack.
dbreads
Package dbreads holds the shared read queries used by the api stack.
Package dbreads holds the shared read queries used by the api stack.
Package runtime provides operations for runtime-managed tables (instance, instance_application, instance_status_history, event, activity, group_local, instance_stats).
Package runtime provides operations for runtime-managed tables (instance, instance_application, instance_status_history, event, activity, group_local, instance_stats).
Package types holds the domain model shared across the backend: the entities Nebraska persists, the status and event constants describing them, and the sentinel errors returned by operations on them.
Package types holds the domain model shared across the backend: the entities Nebraska persists, the status and event constants describing them, and the sentinel errors returned by operations on them.

Jump to

Keyboard shortcuts

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