types.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package kos
  2. import (
  3. "context"
  4. "git.nspix.com/golang/kos/entry"
  5. "git.nspix.com/golang/kos/entry/cli"
  6. "git.nspix.com/golang/kos/entry/http"
  7. )
  8. type (
  9. // Server custom attach server
  10. Server interface {
  11. Start(ctx context.Context) (err error)
  12. Stop() (err error)
  13. }
  14. // HandleFunc request handle func
  15. HandleFunc func(ctx Context) (err error)
  16. // Application app interface
  17. Application interface {
  18. Info() *Info
  19. Http() *http.Server
  20. Command() *cli.Server
  21. Handle(method string, cb HandleFunc, opts ...HandleOption)
  22. Run() (err error)
  23. }
  24. // Info application information
  25. Info struct {
  26. ID string `json:"id"`
  27. Name string `json:"name"`
  28. Version string `json:"version"`
  29. VcsVersion string `json:"vcsVersion"`
  30. Status string `json:"status"`
  31. Address string `json:"address"`
  32. Port int `json:"port"`
  33. Metadata map[string]string `json:"metadata"`
  34. }
  35. // State application runtime state
  36. State struct {
  37. ID string `json:"id"`
  38. Name string `json:"name"`
  39. Version string `json:"version"`
  40. Uptime string `json:"uptime"`
  41. Gateway *entry.State `json:"gateway"`
  42. }
  43. )