notification.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright 2017 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package client
  14. // Notification are internal messages used for abstracting protocol specific
  15. // messages for clients. isNotification is only present to force typing
  16. // assertions.
  17. type Notification interface {
  18. isNotification()
  19. }
  20. // Update is an update to the leaf in the tree.
  21. type Update Leaf
  22. func (u Update) isNotification() {}
  23. // Delete is an explicit delete of the path in the tree.
  24. type Delete Leaf
  25. func (d Delete) isNotification() {}
  26. // Error is a inband error notification. It could be received without breaking
  27. // the query or connection.
  28. type Error struct {
  29. s string
  30. }
  31. // NewError will return a new error with the provided text.
  32. func NewError(s string) Error {
  33. return Error{s: s}
  34. }
  35. // Error is provided to implement the error interface.
  36. func (e Error) Error() string {
  37. return e.s
  38. }
  39. func (e Error) isNotification() {}
  40. // Sync is an inband notification that the client has sent everything in it's
  41. // cache at least once. This does not mean EVERYTHING you wanted is there only
  42. // that the target has sent everything it currently has... which may be nothing.
  43. type Sync struct{}
  44. func (s Sync) isNotification() {}
  45. // Connected is a synthetic notification sent when connection is established.
  46. // It's sent before any other notifications on a new client.
  47. type Connected struct{}
  48. func (s Connected) isNotification() {}