app

package
v2.0.56 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0, Apache-2.0 Imports: 31 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitAppScheme

func InitAppScheme() error

InitAppScheme registers Knative Serving types (Service, Route, Configuration, Revision) into the client-go scheme so that the K8s client can manage KService CRDs. Must be called before creating any K8s clients that interact with apps.

func InitKubernetesCache added in v2.0.45

func InitKubernetesCache(restConfig *rest.Config, scheme *runtime.Scheme) (ctrlcache.Cache, error)

InitKubernetesCache creates the shared controller-runtime cache used by standalone services that install informer handlers. The caller is responsible for starting the returned cache with SetupContext.AddWorker.

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 is the path to a kubeconfig file (empty → in-cluster → default).
	KubeConfig string `json:"kubeconfig" pflag:",Path to kubeconfig file (optional)"`
	// Namespace to ensure exists / operate in.
	Namespace string `json:"namespace" pflag:",Kubernetes namespace"`
	// QPS is the API server queries-per-second limit (0 → client default).
	QPS int `json:"qps" pflag:",Maximum queries per second to the Kubernetes API server"`
	// Burst is the API server burst limit (0 → client default).
	Burst int `json:"burst" pflag:",Maximum burst above QPS for Kubernetes API server requests"`
	// Timeout is the API server request timeout, e.g. "30s" (empty → client default).
	Timeout string `json:"timeout" pflag:",Request timeout for Kubernetes API server calls (e.g. 30s)"`
	// ClusterName is the logical name of this cluster, used by the secret service
	// for secret status reporting.
	ClusterName string `json:"clusterName" pflag:",Logical name of the Kubernetes cluster"`
}

K8sConfig holds Kubernetes connection options used by InitKubernetesClient. It is also the shared `kubernetes` config section for the services (manager, actions, secret), so it carries json/pflag tags.

type ReadyCheckFunc

type ReadyCheckFunc func(r *http.Request) error

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

type ServerError

type ServerError interface {
	Error() string
	Code() codes.Code
	WithDetails(details proto.Message) (ServerError, error)
}

func NewServerError

func NewServerError(code codes.Code, message string) ServerError

func NewServerErrorFromStatus

func NewServerErrorFromStatus(status *status.Status) ServerError

func NewServerErrorf

func NewServerErrorf(code codes.Code, format string, a ...interface{}) ServerError

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 *sqlx.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

	// K8sCache is an optional shared controller-runtime cache.
	K8sCache cache.Cache

	// 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) AddProfilingServer added in v2.0.55

func (sc *SetupContext) AddProfilingServer(name string, port int)

AddProfilingServer registers a profiling worker. A nonpositive port disables it. Services sharing a process must use distinct profiling ports.

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