Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAPIHost(session *Session) *vhttp.VirtualHost
- func GetManifestPathFromArgs(args []string) string
- func Match[T any, U any](path string, cb func(*Session, *http.Request, T) (U, error))
- func MatchLocked[T any, U any](path string, cb func(*Session, *http.Request, T) (U, error))
- func OpenAndServe(manifestPath string)
- func Run(args []string)
- func ServeRPC(originalReq *http.Request, method string, body json.RawMessage) (out json.RawMessage, err error)
- type HostsLine
- type IPInfoOptions
- type IPInfoQuery
- type IPInfoResult
- type JetManifest
- type JetStreamManifest
- type KVCompareAndSwap
- type KVCompareAndSwapResult
- type KVSetIf
- type KVState
- type Lambda
- type LambdaID
- func (l LambdaID) IsZero() bool
- func (l LambdaID) MarshalBinary() ([]byte, error)
- func (l LambdaID) MarshalText() ([]byte, error)
- func (l LambdaID) Peer(session *Session) *xpost.Peer
- func (l LambdaID) String() string
- func (l *LambdaID) UnmarshalBinary(data []byte) error
- func (l *LambdaID) UnmarshalText(data []byte) error
- type LockedHandler
- type Manifest
- type PullResult
- type RepoInfo
- type Runner
- func (t *Runner) ConsumeCore(ctx context.Context, gw *enats.Gateway, subj, queue string) (err error)
- func (t *Runner) ConsumeJetstream(ctx context.Context, gw *enats.Gateway, cns jetstream.Consumer) error
- func (t *Runner) Listen(ctx context.Context, gw *enats.Gateway, topic string) (cancel context.CancelFunc, err error)
- func (t *Runner) ServeCore(ctx context.Context, gw *enats.Gateway, msg *nats.Msg)
- func (t *Runner) ServeJetstream(ctx context.Context, gw *enats.Gateway, msg jetstream.Msg)
- func (t *Runner) ServeMsg(ctx context.Context, subject string, data []byte, meta *jetstream.MsgMetadata, ...) (res []byte, err error)
- type ScheduledRunner
- type Server
- type ServiceCommandResult
- type ServiceEntry
- type ServiceHealth
- type ServiceInvalidate
- type ServiceList
- type ServiceMetrics
- type ServiceState
- type Session
- func (s *Session) Close() error
- func (s *Session) Manifest() *Manifest
- func (s *Session) Open(ctx context.Context) error
- func (s *Session) Reload(invalidate bool) error
- func (s *Session) ReloadLocked(invalidate bool) error
- func (s *Session) ResolveNats() *enats.Client
- func (s *Session) ResolveService(sv string) vhttp.Handler
- func (s *Session) RestartService(match *string, invalidate bool) int
- func (s *Session) Shutdown(ctx context.Context)
- func (s *Session) StartService(name string, sv service.Service, invalidate bool) (*ServiceState, error)
- func (s *Session) StopService(match *string) int
- type SessionMetrics
- type SystemMetrics
- type TypedHandler
- type UpdateParams
Constants ¶
View Source
const ApiRequestMaxDuration = time.Minute
Variables ¶
View Source
var ApiRouter = http.NewServeMux()
Functions ¶
func CreateAPIHost ¶
func CreateAPIHost(session *Session) *vhttp.VirtualHost
func GetManifestPathFromArgs ¶ added in v0.2.0
func MatchLocked ¶
func OpenAndServe ¶ added in v0.2.0
func OpenAndServe(manifestPath string)
func ServeRPC ¶
func ServeRPC(originalReq *http.Request, method string, body json.RawMessage) (out json.RawMessage, err error)
Forwards to serve HTTP
Types ¶
type HostsLine ¶
func (*HostsLine) UnmarshalYAML ¶
type IPInfoOptions ¶
type IPInfoOptions struct { Disable bool `yaml:"disable,omitempty"` MaxmindKey string `yaml:"maxmind,omitempty"` Mark []string `yaml:"mark,omitempty"` }
func (IPInfoOptions) CreateProvider ¶
func (i IPInfoOptions) CreateProvider() (info netx.IPInfoProvider)
type IPInfoQuery ¶
type IPInfoQuery struct {
IP string `json:"ip"`
}
type IPInfoResult ¶
type JetManifest ¶
type JetManifest struct { Streams map[string]JetStreamManifest `yaml:"streams,omitempty"` KV map[string]jetstream.KeyValueConfig `yaml:"kv,omitempty"` Obj map[string]jetstream.ObjectStoreConfig `yaml:"obj,omitempty"` }
type JetStreamManifest ¶
type JetStreamManifest struct { Stream jetstream.StreamConfig `yaml:"stream"` Consumers map[string]jetstream.ConsumerConfig `yaml:"consumers"` }
type KVCompareAndSwap ¶
type KVCompareAndSwap struct { Expected json.RawMessage `json:"expected"` Desired json.RawMessage `json:"desired"` }
type KVCompareAndSwapResult ¶
type KVCompareAndSwapResult struct { OK bool `json:"ok"` Diff json.RawMessage `json:"diff"` Revision uint64 `json:"revision"` Value json.RawMessage `json:"value"` }
type KVSetIf ¶
type KVSetIf struct { Revision uint64 `json:"revision"` Value json.RawMessage `json:"value"` }
type KVState ¶
type KVState struct { Revision uint64 `json:"revision"` Value json.RawMessage `json:"value"` }
type LambdaID ¶
func NewLambdaID ¶
func NewLambdaID() LambdaID
func (LambdaID) MarshalBinary ¶
func (LambdaID) MarshalText ¶
func (*LambdaID) UnmarshalBinary ¶
func (*LambdaID) UnmarshalText ¶
type LockedHandler ¶
func (LockedHandler) ServeHTTP ¶
func (h LockedHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type Manifest ¶
type Manifest struct { Root string `yaml:"root,omitempty"` // Root directory ServiceRoot string `yaml:"service_root,omitempty"` // Service root directory Services util.OrderedMap[string, service.Service] `yaml:"services,omitempty"` // Services Server map[string]*Server `yaml:"server,omitempty"` // Virtual hosts IPInfo IPInfoOptions `yaml:"ipinfo,omitempty"` // IP information provider Env map[string]string `yaml:"env,omitempty"` // Environment variables Runners map[string]*Runner `yaml:"runners,omitempty"` // Runners Jet JetManifest `yaml:"jet,omitempty"` // JetStream configuration Hosts []HostsLine `yaml:"hosts,omitempty"` // Hostname to IP mapping CustomErrors string `yaml:"custom_errors,omitempty"` // Path to custom error pages }
func LoadManifest ¶
type PullResult ¶
type Runner ¶
type Runner struct { Route vhttp.HandleMux `yaml:"route,omitempty"` // HTTP route for the task Schedule []ScheduledRunner `yaml:"schedule,omitempty"` // Schedule for the task Rate rate.Rate `yaml:"rate,omitempty"` // Rate limit for the task NoDeadLetter bool `yaml:"no_dead_letter,omitempty"` // Do not send to dead letter retry.Policy `yaml:",inline"` }
func (*Runner) ConsumeCore ¶ added in v0.3.2
func (*Runner) ConsumeJetstream ¶ added in v0.3.2
func (*Runner) ServeJetstream ¶ added in v0.3.2
type ScheduledRunner ¶
type Server ¶
type Server struct { vhttp.VirtualHostOptions `yaml:",inline"` Router vhttp.HandleMux `yaml:"router,omitempty"` }
func (*Server) CreateVirtualHost ¶
func (sv *Server) CreateVirtualHost() *vhttp.VirtualHost
type ServiceCommandResult ¶
type ServiceCommandResult struct {
Count int `json:"count"`
}
type ServiceEntry ¶
type ServiceHealth ¶
type ServiceHealth struct { Status string `json:"status"` // Status Healthy int `json:"healthy"` // Number of healthy instances Total int `json:"total"` // Total number of instances Err string `json:"err,omitempty"` // Error message }
func (*ServiceHealth) Fill ¶
func (h *ServiceHealth) Fill(sv *ServiceState)
type ServiceInvalidate ¶
type ServiceInvalidate struct {
Invalidate bool `json:"invalidate"`
}
type ServiceList ¶
type ServiceList struct {
Services []ServiceEntry `json:"services"`
}
type ServiceMetrics ¶
type ServiceMetrics struct { ID snowflake.ID `json:"id"` Type string `json:"type"` Server lb.LoadBalancerMetrics `json:"server"` Processes []service.ProcTreeMetrics `json:"processes"` ServiceHealth }
func (*ServiceMetrics) Fill ¶
func (m *ServiceMetrics) Fill(sv *ServiceState)
type ServiceState ¶
type ServiceState struct { service.Instance ID snowflake.ID // contains filtered or unexported fields }
func (*ServiceState) Err ¶
func (s *ServiceState) Err() error
func (*ServiceState) GetLoadBalancer ¶
func (s *ServiceState) GetLoadBalancer() (*lb.LoadBalancer, bool)
func (*ServiceState) GetProcessTrees ¶
func (s *ServiceState) GetProcessTrees() ([]service.ProcessTree, bool)
func (*ServiceState) Shutdown ¶
func (s *ServiceState) Shutdown(ctx context.Context)
func (*ServiceState) Stop ¶
func (s *ServiceState) Stop()
type Session ¶
type Session struct { ID snowflake.ID Context context.Context Cancel context.CancelFunc Server *vhttp.Server Nats *enats.Gateway Peerlist *xpost.Peerlist ManifestPath string // immut ServiceMap concurrent.Map[string, *ServiceState] TaskSubscriptions []context.CancelFunc util.TimedMutex // contains filtered or unexported fields }
func RequestSession ¶
func (*Session) ReloadLocked ¶
func (*Session) ResolveNats ¶
func (*Session) RestartService ¶
func (*Session) StartService ¶
func (*Session) StopService ¶
type SessionMetrics ¶
type SessionMetrics struct { NumClients int `json:"num_clients"` Clients map[string]vhttp.ClientMetrics `json:"sessions"` }
type SystemMetrics ¶
type SystemMetrics struct { MachineID string `json:"machine_id"` CPU cpu.InfoStat `json:"cpu"` Load float64 `json:"load"` Rx float64 `json:"rx"` Tx float64 `json:"tx"` FreeDisk uint64 `json:"freedisk"` FreeMem uint64 `json:"freemem"` TotalDisk uint64 `json:"totaldisk"` TotalMem uint64 `json:"totalmem"` Uptime uint64 `json:"uptime"` // seconds Hostname string `json:"hostname"` UID string `json:"uid"` ProcessCount uint64 `json:"process_count"` OS string `json:"os"` KernelVersion string `json:"kernel_version"` KernelArch string `json:"kernel_arch"` VirtualizationSystem string `json:"virtualization_system"` VirtualizationRole string `json:"virtualization_role"` RTT map[string]float64 `json:"rtt"` }
func GetSystemMetrics ¶
func GetSystemMetrics(session *Session) (m SystemMetrics)
type TypedHandler ¶
Handler: func(arg T, req *http.Request) (result U, err error)
func (TypedHandler[T, U]) ServeHTTP ¶
func (h TypedHandler[T, U]) ServeHTTP(w http.ResponseWriter, req *http.Request)
type UpdateParams ¶
type UpdateParams struct {
Invalidate bool `json:"invalidate"` // True if the session should be invalidated
}
Click to show internal directories.
Click to hide internal directories.