model.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package services
  2. type (
  3. protocol string
  4. schema string
  5. )
  6. const (
  7. REST protocol = "rest"
  8. GRPC = "grpc"
  9. MSGPACK = "msgpack-rpc"
  10. )
  11. const (
  12. PROTOBUFF schema = "protobuf"
  13. )
  14. type (
  15. author struct {
  16. Name string `json:"name"`
  17. Email string `json:"email"`
  18. Company string `json:"company"`
  19. Website string `json:"website"`
  20. }
  21. fileLanguage struct {
  22. English string `json:"en_US"`
  23. Chinese string `json:"zh_CN"`
  24. }
  25. about struct {
  26. Author *author `json:"author"`
  27. HelpUrl *fileLanguage `json:"helpUrl"`
  28. Description *fileLanguage `json:"description"`
  29. }
  30. mapping struct {
  31. Name string `json:"name"`
  32. ServiceName string `json:"serviceName"`
  33. Description *fileLanguage `json:"description"`
  34. }
  35. binding struct {
  36. Name string `json:"name"`
  37. Description *fileLanguage `json:"description"`
  38. Address string `json:"address"`
  39. Protocol protocol `json:"protocol"`
  40. SchemaType schema `json:"schemaType"`
  41. SchemaFile string `json:"schemaFile"`
  42. Functions []*mapping `json:"functions"`
  43. Options map[string]interface{} `json:"options"`
  44. }
  45. conf struct {
  46. About *about `json:"about"`
  47. Interfaces map[string]*binding `json:"interfaces"`
  48. }
  49. )
  50. // The external function's location, currently service.interface.
  51. type serviceInfo struct {
  52. About *about
  53. Interfaces map[string]*interfaceInfo
  54. }
  55. type schemaInfo struct {
  56. SchemaType schema
  57. SchemaFile string
  58. }
  59. type interfaceInfo struct {
  60. Desc *fileLanguage
  61. Addr string
  62. Protocol protocol
  63. Schema *schemaInfo
  64. Functions []string
  65. Options map[string]interface{}
  66. }
  67. type restOption struct {
  68. InsecureSkipVerify bool `json:"insecureSkipVerify"`
  69. Headers map[string]string `json:"headers"`
  70. }
  71. type functionContainer struct {
  72. ServiceName string
  73. InterfaceName string
  74. MethodName string
  75. }
  76. type FunctionExec struct {
  77. Protocol protocol
  78. Addr string
  79. }