server

package module
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: Apache-2.0 Imports: 9 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth added in v1.5.6

type Auth interface {
	// Authenticate attempts to identify and return the user associated with
	// an incoming HTTP request, typically by inspecting headers or tokens.
	Authenticate(*http.Request) (*authschema.User, error)

	// Authorize checks if a given user has the necessary permissions (scopes)
	// to perform an action.
	Authorize(context.Context, *authschema.User, ...string) error
}

Auth defines methods for authenticating users based on HTTP requests and authorizing them based on required scopes.

type Cmd added in v1.5.6

type Cmd interface {
	// Return the context
	Context() context.Context

	// Return the debug mode
	GetDebug() DebugLevel

	// Return the endpoint
	GetEndpoint(paths ...string) *url.URL

	// Return the HTTP client options
	GetClientOpts() []client.ClientOpt
}

Cmd represents the command line interface context

type CmdOffsetLimit added in v1.5.6

type CmdOffsetLimit struct {
	Offset uint64  `name:"offset" help:"List item offset"`
	Limit  *uint64 `name:"limit" help:"List item limit"`
}

type DebugLevel added in v1.5.6

type DebugLevel uint
const (
	None DebugLevel = iota
	Debug
	Trace
)

type HTTPMiddleware added in v1.5.0

type HTTPMiddleware interface {
	// Return a http handler with middleware as the parent handler
	HandleFunc(http.HandlerFunc) http.HandlerFunc
}

type HTTPRouter added in v1.5.0

type HTTPRouter interface {
	// Return the CORS origin
	Origin() string

	// Register a function to handle a URL path
	HandleFunc(context.Context, string, http.HandlerFunc)

	// Register serving of static files from a filesystem
	HandleFS(context.Context, string, fs.FS)
}

type Logger

type Logger interface {
	HTTPMiddleware

	// Debug logs a debugging message.
	Debug(context.Context, ...any)

	// Debugf logs a formatted debugging message.
	Debugf(context.Context, string, ...any)

	// Print logs an informational message.
	Print(context.Context, ...any)

	// Printf logs a formatted informational message.
	Printf(context.Context, string, ...any)

	// With returns a new Logger that includes the given key-value pairs
	// in its structured log output.
	With(...any) Logger
}

Logger defines methods for logging messages and structured data. It can also act as HTTP middleware for request logging.

type PG added in v1.5.5

type PG interface {
	// Conn returns the underlying connection pool object.
	Conn() pg.PoolConn
}

PG provides access to a PostgreSQL connection pool.

type PGCallback added in v1.5.5

type PGCallback func(context.Context, any) error

PGCallback defines the function signature for handling tasks dequeued from a PostgreSQL-backed queue.

type PGQueue added in v1.5.5

type PGQueue interface {
	// RegisterTicker registers a periodic task (ticker) with a callback function.
	// It returns the metadata of the registered ticker.
	RegisterTicker(context.Context, pgschema.TickerMeta, PGCallback) (*pgschema.Ticker, error)

	// RegisterQueue registers a task queue with a callback function.
	// It returns the metadata of the registered queue.
	RegisterQueue(context.Context, pgschema.QueueMeta, PGCallback) (*pgschema.Queue, error)

	// CreateTask adds a new task to a specified queue with a payload and optional delay.
	// It returns the metadata of the created task.
	CreateTask(context.Context, string, any, time.Duration) (*pgschema.Task, error)

	// UnmarshalPayload unmarshals a payload into a destination object.
	UnmarshalPayload(dest any, payload any) error
}

PGQueue defines methods for interacting with a PostgreSQL-backed task queue.

type Plugin

type Plugin interface {
	// Return the unique name for the plugin
	Name() string

	// Return a description of the plugin
	Description() string

	// Create a task from a plugin
	New(context.Context) (Task, error)
}

Plugin represents a service

type Provider

type Provider interface {
	Task

	// Return a task given a plugin label
	Task(context.Context, string) Task
}

Provider represents a service provider

type Task added in v1.0.48

type Task interface {
	// Run a task
	Run(context.Context) error
}

Task represents a service task

Jump to

Keyboard shortcuts

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