app

package
v2.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(ctx context.Context, cfg *database.DbConfig) (*gorm.DB, error)

InitDB creates a gorm.DB from the given config.

func InitKubernetesClient

func InitKubernetesClient(ctx context.Context, cfg K8sConfig, scheme *runtime.Scheme) (client.WithWatch, *rest.Config, error)

InitKubernetesClient creates a controller-runtime WithWatch client. It tries in-cluster config first, then falls back to the default kubeconfig. If namespace is non-empty and Scheme is provided, it ensures the namespace exists.

Types

type App

type App struct {
	// Name is the cobra command name (e.g. "flyte", "runs-service").
	Name string

	// Short is the short description shown in --help.
	Short string

	// Setup is called after config initialisation. It should populate the
	// SetupContext with shared resources and register HTTP handlers / workers.
	Setup func(ctx context.Context, sc *SetupContext) error
}

App is the shared entry-point skeleton for Flyte services.

func (*App) Command

func (a *App) Command() *cobra.Command

Command returns the root cobra.Command with config init wired in.

func (*App) Run

func (a *App) Run() error

Run builds the cobra command and executes it.

type K8sConfig

type K8sConfig struct {
	KubeConfig string // path to kubeconfig (empty → in-cluster → default)
	Namespace  string // namespace to ensure exists
	QPS        int    // API server QPS limit
	Burst      int    // API server burst limit
	Timeout    string // API server request timeout (e.g. "30s")
}

K8sConfig holds Kubernetes connection options used by InitKubernetesClient.

type ReadyCheckFunc

type ReadyCheckFunc func(r *http.Request) error

ReadyCheckFunc is called on /readyz requests. Return nil for healthy.

type SetupContext

type SetupContext struct {
	// Server address. Defaults to "0.0.0.0" and 8080.
	Host string
	Port int

	// Mux is the HTTP serve mux to register handlers on.
	Mux *http.ServeMux

	// DB is the shared database connection (may be nil if service doesn't need it).
	DB *gorm.DB

	// K8sClient is the Kubernetes client with watch support (may be nil).
	K8sClient client.WithWatch

	// K8sConfig is the Kubernetes REST config (may be nil).
	K8sConfig *rest.Config

	// DataStore is the object storage client (may be nil).
	DataStore *storage.DataStore

	// Namespace is the Kubernetes namespace for CRs.
	Namespace string

	// BaseURL is the base URL for intra-service calls (e.g. "http://localhost:8090").
	// In unified mode the manager sets this so all services call each other
	// via the same mux. Standalone binaries leave it empty and use their own
	// per-service config for remote URLs.
	BaseURL string

	// Scope is the metrics scope.
	Scope promutils.Scope

	// Middleware wraps the final HTTP handler (e.g. CORS).
	Middleware func(http.Handler) http.Handler
	// contains filtered or unexported fields
}

SetupContext carries shared resources to service Setup functions. New fields can be added here without changing any Setup() signature.

func (*SetupContext) AddReadyCheck

func (sc *SetupContext) AddReadyCheck(fn ReadyCheckFunc)

AddReadyCheck registers a readiness check invoked on /readyz.

func (*SetupContext) AddWorker

func (sc *SetupContext) AddWorker(name string, fn WorkerFunc)

AddWorker registers a background goroutine that runs alongside the HTTP server. The worker should block until ctx is cancelled.

type WorkerFunc

type WorkerFunc func(ctx context.Context) error

WorkerFunc is a long-running function (e.g. controller-runtime manager) that runs alongside the HTTP server. It should block until ctx is cancelled.

Jump to

Keyboard shortcuts

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