kos/types.go

49 lines
1.2 KiB
Go

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
Handle(method string, cb HandleFunc, opts ...HandleOption)
}
// 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"`
}
)