client.go 820 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package paladin
  2. import (
  3. "context"
  4. )
  5. const (
  6. // EventAdd config add event.
  7. EventAdd EventType = iota
  8. // EventUpdate config update event.
  9. EventUpdate
  10. // EventRemove config remove event.
  11. EventRemove
  12. )
  13. // EventType is config event.
  14. type EventType int
  15. // Event is watch event.
  16. type Event struct {
  17. Event EventType
  18. Key string
  19. Value string
  20. }
  21. // Watcher is config watcher.
  22. type Watcher interface {
  23. WatchEvent(context.Context, ...string) <-chan Event
  24. Close() error
  25. }
  26. // Setter is value setter.
  27. type Setter interface {
  28. Set(string) error
  29. }
  30. // Getter is value getter.
  31. type Getter interface {
  32. // Get a config value by a config key(may be a sven filename).
  33. Get(string) *Value
  34. // GetAll return all config key->value map.
  35. GetAll() *Map
  36. }
  37. // Client is config client.
  38. type Client interface {
  39. Watcher
  40. Getter
  41. }