2023-04-23 17:57:36 +08:00
|
|
|
package kos
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"git.nspix.com/golang/kos/entry"
|
|
|
|
"git.nspix.com/golang/kos/entry/cli"
|
|
|
|
"git.nspix.com/golang/kos/entry/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
// Server custom attach server
|
|
|
|
Server interface {
|
|
|
|
Start(ctx context.Context) (err error)
|
|
|
|
Stop() (err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// HandleFunc request handle func
|
|
|
|
HandleFunc func(ctx Context) (err error)
|
|
|
|
|
|
|
|
// Application app interface
|
|
|
|
Application interface {
|
|
|
|
Info() *Info
|
|
|
|
Http() *http.Server
|
|
|
|
Command() *cli.Server
|
2024-01-18 17:11:44 +08:00
|
|
|
Handle(method string, cb HandleFunc, opts ...HandleOption)
|
2024-04-29 10:52:19 +08:00
|
|
|
Run() (err error)
|
2023-04-23 17:57:36 +08:00
|
|
|
}
|
2024-01-18 17:11:44 +08:00
|
|
|
|
2023-04-23 17:57:36 +08:00
|
|
|
// Info application information
|
|
|
|
Info struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
VcsVersion string `json:"vcsVersion"`
|
|
|
|
Status string `json:"status"`
|
|
|
|
Address string `json:"address"`
|
|
|
|
Port int `json:"port"`
|
|
|
|
Metadata map[string]string `json:"metadata"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// State application runtime state
|
|
|
|
State struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
Uptime string `json:"uptime"`
|
|
|
|
Gateway *entry.State `json:"gateway"`
|
|
|
|
}
|
|
|
|
)
|