This is an automated email from the ASF dual-hosted git repository.
chenjunxu pushed a commit to branch refactor
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/refactor by this push:
new 7490f7f chore: add structures (#484)
7490f7f is described below
commit 7490f7fe85b8d569805eff0066862183b3c80387
Author: nic-chen <[email protected]>
AuthorDate: Sat Sep 19 08:47:00 2020 +0800
chore: add structures (#484)
* add upstream struct
* fix structures
---
api/internal/core/entity/entity.go | 104 +++++++++++++++++++++++++++++++++++--
1 file changed, 100 insertions(+), 4 deletions(-)
diff --git a/api/internal/core/entity/entity.go
b/api/internal/core/entity/entity.go
index c3ed12f..c81377b 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -2,7 +2,7 @@ package entity
type Route struct {
ID string `json:"id"`
- Uri string `json:"uri,omitempty" validate:"uri"`
+ URI string `json:"uri,omitempty" validate:"uri"`
Uris []string `json:"uris,omitempty"`
Name string `json:"name,omitempty" validate:"max=50"`
Desc string `json:"desc,omitempty" validate:"max=256"`
@@ -11,16 +11,112 @@ type Route struct {
Host string `json:"host,omitempty"`
Hosts []string `json:"hosts,omitempty"`
RemoteAddr string `json:"remote_addr,omitempty"`
- RemoteAddrs string `json:"remote_addrs,omitempty"`
+ RemoteAddrs []string `json:"remote_addrs,omitempty"`
Vars string `json:"vars,omitempty"`
FilterFunc string `json:"filter_func,omitempty"`
Script string `json:"script,omitempty"`
Plugins interface{} `json:"plugins,omitempty"`
Upstream Upstream `json:"upstream,omitempty"`
- ServiceId string `json:"service_id,omitempty"`
- UpstreamId string `json:"upstream_id,omitempty"`
+ ServiceID string `json:"service_id,omitempty"`
+ UpstreamID string `json:"upstream_id,omitempty"`
ServiceProtocol string `json:"service_protocol,omitempty"`
}
+// --- structures for upstream start ---
+type Timeout struct {
+ Connect int `json:"connect,omitempty"`
+ Send int `json:"send,omitempty"`
+ Read int `json:"read,omitempty"`
+}
+
+type Node struct {
+ Host string `json:"host,omitempty"`
+ Port int `json:"port,omitempty"`
+ Weight int `json:"weight,omitempty"`
+ Metadata interface{} `json:"metadata,omitempty"`
+}
+
+type K8sInfo struct {
+ Namespace string `json:"namespace,omitempty"`
+ DeployName string `json:"deploy_name,omitempty"`
+ ServiceName string `json:"service_name,omitempty"`
+ Port int `json:"port,omitempty"`
+ BackendType string `json:"backend_type,omitempty"`
+}
+
+type Healthy struct {
+ Interval int `json:"interval,omitempty"`
+ HttpStatuses []int `json:"http_statuses,omitempty"`
+ Successes int `json:"successes,omitempty"`
+}
+
+type UnHealthy struct {
+ Interval int `json:"interval,omitempty"`
+ HTTPStatuses []int `json:"http_statuses,omitempty"`
+ TCPFailures int `json:"tcp_failures,omitempty"`
+ Timeouts int `json:"timeouts,omitempty"`
+ HTTPFailures int `json:"http_failures,omitempty"`
+}
+
+type Active struct {
+ Type string `json:"type,omitempty"`
+ Timeout int `json:"timeout,omitempty"`
+ Concurrency int `json:"concurrency,omitempty"`
+ Host string `json:"host,omitempty"`
+ Port int `json:"port,omitempty"`
+ HTTPPath string `json:"http_path,omitempty"`
+ HTTPSVerifyCertificate string
`json:"https_verify_certificate,omitempty"`
+ Healthy Healthy `json:"healthy,omitempty"`
+ UnHealthy UnHealthy `json:"unhealthy,omitempty"`
+ ReqHeaders []string `json:"req_headers,omitempty"`
+}
+
+type Passive struct {
+ Type string `json:"type,omitempty"`
+ Healthy Healthy `json:"healthy,omitempty"`
+ UnHealthy UnHealthy `json:"unhealthy,omitempty"`
+}
+
+type HealthChecker struct {
+ Active Active `json:"active,omitempty"`
+ Passive Passive `json:"passive,omitempty"`
+}
+
type Upstream struct {
+ Nodes []Node `json:"nodes,omitempty"`
+ Retries int `json:"retries,omitempty"`
+ Timeout Timeout `json:"timeout,omitempty"`
+ K8sInfo K8sInfo `json:"k8s_deployment_info,omitempty"`
+ Type string `json:"type,omitempty"`
+ Checks HealthChecker `json:"checks,omitempty"`
+ HashOn string `json:"hash_on,omitempty"`
+ Key string `json:"key,omitempty"`
+ EnableWebsocket bool `json:"enable_websocket,omitempty"`
+ PassHost string `json:"pass_host,omitempty"`
+ UpstreamHost string `json:"upstream_host,omitempty"`
+ Name string `json:"name,omitempty"`
+ Desc string `json:"desc,omitempty"`
+ ServiceName string `json:"service_name,omitempty"`
+ ID string `json:"id,omitempty"`
+}
+
+// --- structures for upstream end ---
+
+type Consumer struct {
+ ID string `json:"id"`
+ Username string `json:"username"`
+ Desc string `json:"desc,omitempty"`
+ Plugins interface{} `json:"plugins,omitempty"`
+}
+
+type Ssl struct {
+ ID string `json:"id"`
+ Cert string `json:"cert"`
+ Key string `json:"key"`
+ Sni string `json:"sni"`
+ Snis []string `json:"snis"`
+ Certs []string `json:"certs"`
+ Keys []string `json:"keys"`
+ ExpTime int `json:"exptime"`
+ Status int `json:"status"`
}