model.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright 2021 EMQ Technologies Co., Ltd.
  2. //
  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. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package service
  15. type (
  16. protocol string
  17. schema string
  18. )
  19. const (
  20. REST protocol = "rest"
  21. GRPC = "grpc"
  22. MSGPACK = "msgpack-rpc"
  23. )
  24. const (
  25. PROTOBUFF schema = "protobuf"
  26. )
  27. type (
  28. author struct {
  29. Name string `json:"name"`
  30. Email string `json:"email"`
  31. Company string `json:"company"`
  32. Website string `json:"website"`
  33. }
  34. fileLanguage struct {
  35. English string `json:"en_US"`
  36. Chinese string `json:"zh_CN"`
  37. }
  38. about struct {
  39. Author *author `json:"author"`
  40. HelpUrl *fileLanguage `json:"helpUrl"`
  41. Description *fileLanguage `json:"description"`
  42. }
  43. mapping struct {
  44. Name string `json:"name"`
  45. ServiceName string `json:"serviceName"`
  46. Description *fileLanguage `json:"description"`
  47. }
  48. binding struct {
  49. Name string `json:"name"`
  50. Description *fileLanguage `json:"description"`
  51. Address string `json:"address"`
  52. Protocol protocol `json:"protocol"`
  53. SchemaType schema `json:"schemaType"`
  54. SchemaFile string `json:"schemaFile"`
  55. Functions []*mapping `json:"functions"`
  56. Options map[string]interface{} `json:"options"`
  57. }
  58. conf struct {
  59. About *about `json:"about"`
  60. Interfaces map[string]*binding `json:"interfaces"`
  61. }
  62. )
  63. // The external function's location, currently service.interface.
  64. type serviceInfo struct {
  65. About *about
  66. Interfaces map[string]*interfaceInfo
  67. }
  68. type schemaInfo struct {
  69. SchemaType schema
  70. SchemaFile string
  71. }
  72. type interfaceInfo struct {
  73. Desc *fileLanguage
  74. Addr string
  75. Protocol protocol
  76. Schema *schemaInfo
  77. Functions []string
  78. Options map[string]interface{}
  79. }
  80. type restOption struct {
  81. InsecureSkipVerify bool `json:"insecureSkipVerify"`
  82. Headers map[string]string `json:"headers"`
  83. }
  84. type functionContainer struct {
  85. ServiceName string
  86. InterfaceName string
  87. MethodName string
  88. }
  89. type FunctionExec struct {
  90. Protocol protocol
  91. Addr string
  92. }