golazy.dev
–
golazy.dev
/
lazydeps
Index
|
Files
package lazydeps ¶
import "golazy.dev/lazydeps"
Constants ¶
const LazyDevDependenciesPath ¶
const LazyDevDependenciesPath = "/dependencies"
const LazyDevDependencyShutdownEventsPath ¶
const LazyDevDependencyShutdownEventsPath = "/dependencies/shutdown/events"
const LazyDevDependencyShutdownPath ¶
const LazyDevDependencyShutdownPath = "/dependencies/shutdown"
Functions ¶
func RegisterLazyDevHandlers ¶
RegisterLazyDevHandlers registers dependency graph inspection endpoints.
func RegisterLazyDevHandlers(controlPlane *lazycontrolplane.ControlPlane, dependencies *Scope, opts ...LazyDevOption)
Types ¶
type Edge ¶
type Edge struct {
From string `json:"from"`
To string `json:"to"`
}
type Func ¶
type Func[T any] func(context.Context) (context.Context, T, error, context.CancelFunc)
type Graph ¶
type Graph struct {
Nodes []string `json:"nodes"`
Edges []Edge `json:"edges"`
}
type LazyDevOption ¶
type LazyDevOption func(*lazyDevOptions)
func WithLazyDevRuntime ¶
WithLazyDevRuntime lets lazydev dependency handlers report readiness, active requests, and active connections while simulating shutdown.
func WithLazyDevRuntime(runtime LazyDevRuntime) LazyDevOption
type LazyDevRuntime ¶
LazyDevRuntime reports application runtime state to dependency development handlers.
type LazyDevRuntime interface {
SetDraining(bool)
Draining() bool
ActiveRequests() int64
ActiveConnections() int64
}
type LazyDevShutdownNode ¶
type LazyDevShutdownNode struct {
Name string `json:"name"`
State string `json:"state"`
}
type LazyDevShutdownState ¶
type LazyDevShutdownState struct {
Graph Graph `json:"graph"`
Ready bool `json:"ready"`
ReadyStatus int `json:"ready_status"`
ReadyText string `json:"ready_text"`
ActiveRequests int64 `json:"active_requests"`
ActiveConnections int64 `json:"active_connections"`
Running bool `json:"running"`
Phase string `json:"phase"`
Message string `json:"message"`
Nodes []LazyDevShutdownNode `json:"nodes"`
Error string `json:"error,omitempty"`
}
type Option ¶
type Option func(*Scope)
func WithLogger ¶
func WithLogger(logger *slog.Logger) Option
type Ref ¶
type Ref[T any] struct {
// contains filtered or unexported fields
}
func Service[T any] ¶
func Service[T any](u *Scope, name string, fn Func[T]) (Ref[T], error)
func (r Ref[T]) Use ¶
func (r Ref[T]) Use() T
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, opts ...Option) *Scope
func (u *Scope) Context ¶
func (u *Scope) Context() context.Context
func (u *Scope) Graph ¶
func (u *Scope) Graph() Graph
func (u *Scope) SetContext ¶
func (u *Scope) SetContext(ctx context.Context)
func (u *Scope) Shutdown ¶
func (u *Scope) Shutdown(ctx context.Context, reason string) error
Package lazydeps records application dependency initialization and the dependency graph between services.
Applications receive a *Scope from lazyapp.Config.Dependencies and initialize shared services with Service. Service returns a typed Ref; calling Ref.Use inside another service initializer records that dependency edge and returns the wrapped service value.