kos/types.go

50 lines
1.2 KiB
Go
Raw Normal View History

2023-04-23 17:57:36 +08:00
package kos
import (
"context"
2024-11-12 17:47:28 +08:00
"git.nobla.cn/golang/kos/entry"
"git.nobla.cn/golang/kos/entry/cli"
"git.nobla.cn/golang/kos/entry/http"
2023-04-23 17:57:36 +08:00
)
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"`
}
)