request.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * EliasDB
  3. *
  4. * Copyright 2016 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. */
  10. package cluster
  11. import "encoding/gob"
  12. func init() {
  13. // Make sure we can use the relevant types in a gob operation
  14. gob.Register(&DataRequest{})
  15. gob.Register(make(map[string]string))
  16. }
  17. /*
  18. RequestType is the type of a request
  19. */
  20. type RequestType string
  21. /*
  22. List of all possible request types
  23. */
  24. const (
  25. // Main DB
  26. RTGetMain RequestType = "GetMain"
  27. RTSetMain = "SetMain"
  28. // Roots
  29. RTGetRoot = "GetRoot"
  30. RTSetRoot = "SetRoot"
  31. // Insert data
  32. RTInsert = "Insert"
  33. // Update data
  34. RTUpdate = "Update"
  35. // Free data
  36. RTFree = "Free"
  37. // Check for data
  38. RTExists = "Exists"
  39. // Retrieve data
  40. RTFetch = "Fetch"
  41. // Rebalance data
  42. RTRebalance = "Rebalance"
  43. )
  44. /*
  45. DataRequestArg is a data request argument
  46. */
  47. type DataRequestArg string
  48. /*
  49. List of all possible data request parameters.
  50. */
  51. const (
  52. RPStoreName DataRequestArg = "StoreName" // Name of the store
  53. RPLoc = "Loc" // Location of data
  54. RPVer = "Ver" // Version of data
  55. RPRoot = "Root" // Root id
  56. RPSrc = "Src" // Request source member
  57. )
  58. /*
  59. DataRequest data structure
  60. */
  61. type DataRequest struct {
  62. RequestType RequestType // Type of request
  63. Args map[DataRequestArg]interface{} // Request arguments
  64. Value interface{} // Request value
  65. Transfer bool // Flag for data transfer request
  66. }