todo.go 775 B

1234567891011121314151617181920212223242526272829303132333435
  1. package todosvc
  2. import (
  3. "github.com/go-kit/kit/endpoint"
  4. "golang.org/x/net/context"
  5. )
  6. type Item struct {
  7. ID ID
  8. Title string
  9. Complete bool
  10. }
  11. type ID int64
  12. // Todo is a more advanced example then Add from addsvc.
  13. // It illustrates how to create an service with multiple endpoints combined in a single interface.
  14. type Todo interface {
  15. // Add adds a new Item and returns its ID
  16. Add(context.Context, string) (ID, error)
  17. // List returns a slice of all the items on this service
  18. List(context.Context) ([]Item, error)
  19. // Tooggle toggles the Complete field of an item
  20. Toggle(context.Context, ID) error
  21. // Delete removes the Item from the service
  22. Delete(context.Context, ID) error
  23. }
  24. type Endpoints struct {
  25. Add, List, Toggle, Delete endpoint.Endpoint
  26. }