admin

package
v0.20.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//BalanceTypeRoundrobin roundrobin strategy
	BalanceTypeRoundrobin = "roundrobin"
	//BalanceTypeChash chash strategy
	BalanceTypeChash = "chash"

	//ProtocolHTTP protocol http
	ProtocolHTTP = "http"
	//ProtocolGrpc protocol grpc
	ProtocolGrpc = "grpc"

	//IndexKeyRemoteAddr key define for remote_addr
	IndexKeyRemoteAddr = "remote_addr"
	//IndexKeyServerAddr key define for server_addr
	IndexKeyServerAddr = "server_addr"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic struct {
	Action  string `json:"action"`
	Count   string `json:"count"`
	Data    *Data  `json:"node,omitempty"`
	Message string `json:"message,omitempty"`
	Err     string `json:"error_msg,omitempty"`
}

Basic response from apisix admin interface

type Client

type Client interface {
	//upstream operation
	GetUpstream(id string) (*Upstream, error)
	ListUpstream() ([]*Upstream, error)
	//create upstream, upstream id will auto generate by apisix when not setting
	CreateUpstream(upstr *Upstream) error
	UpdateUpstream(upstr *Upstream) error
	DeleteUpstream(id string) error

	//service operation
	GetService(id string) (*Service, error)
	ListService() ([]*Service, error)
	CreateService(svc *Service) error
	UpdateService(svc *Service) error
	DeleteService(id string) error

	//route operation
	GetRoute(id string) (*Route, error)
	ListRoute() ([]*Route, error)
	CreateRoute(route *Route) error
	UpdateRoute(route *Route) error
	DeleteRoute(id string) error
}

Client definition for apisix admin api

func NewClient

func NewClient(option *Option) Client

NewClient create apisix admin api client

type Data

type Data struct {
	Directory     bool   `json:"dir,omitempty"`
	Key           string `json:"key"`
	CreateIndex   uint   `json:"createdIndex"`
	ModifiedIndex uint   `json:"modifiedIndex"`
	//! when no data response from apisix, response.Data.Nodes is {} and Basic.Count is 1.
	//* if any services response from apisix, response.Data.Node is slice
	Nodes json.RawMessage `json:"nodes,omitempty"`
	Value json.RawMessage `json:"value,omitempty"`
}

Data information from apisix admin interface

type LimitRequest

type LimitRequest struct {
	Rate  uint   `json:"rate"`
	Burst uint   `json:"burst"`
	Key   string `json:"key"`
	//default 503
	RejectCode uint `json:"reject_code,omitempty"`
}

LimitRequest plugin definition

type Node

type Node struct {
	Key           string          `json:"key"`
	CreateIndex   uint            `json:"createdIndex"`
	ModifiedIndex uint            `json:"modifiedIndex"`
	Value         json.RawMessage `json:"value"`
}

Node data holder

type Nodes

type Nodes []*Node

Nodes for Data.Nodes

type Option

type Option struct {
	AdminToken string
	TLSConfig  *tls.Config
	Addrs      []string
}

Option client option

type ProxyRewrite

type ProxyRewrite struct {
	Scheme   string            `json:"scheme,omitempty"`
	URI      string            `json:"uri,omitempty"`
	RegexURI []string          `json:"regex_uri,omitempty"`
	Host     string            `json:"host,omitempty"`
	Header   map[string]string `json:"headers,omitempty"`
}

ProxyRewrite plugin definition

type RequestID

type RequestID struct {
	HeaderName      string `json:"header_name,omitempty"`
	IncludeResponse bool   `json:"include_in_response,omitempty"`
}

RequestID plugin definition

type Route

type Route struct {
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
	// match rules
	URI         string            `json:"uri,omitempty"`
	URIs        []string          `json:"uris,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Host        string            `json:"host,omitempty"`
	Hosts       []string          `json:"hosts,omitempty"`
	RemoteAddr  string            `json:"remote_addr,omitempty"`
	RemoteAddrs []string          `json:"remote_addrs,omitempty"`
	Method      []string          `json:"methods,omitempty"`
	Priority    int               `json:"priority,omitempty"`
	Vars        [][]string        `json:"vars,omitempty"`
	//information
	ServiceProtocol string                 `json:"service_protocol,omitempty"`
	Plugins         map[string]interface{} `json:"plugins,omitempty"`
	Upstream        *Upstream              `json:"upstream,omitempty"`
	UpstreamID      string                 `json:"upstream_id,omitempty"`
	Service         *Service               `json:"service,omitempty"`
	ServiceID       string                 `json:"service_id,omitempty"`
	//Status: 1 up, 0 down
	Status     int  `json:"status,omitempty"`
	Websocket  bool `json:"enable_websocket,omitempty"`
	CreateTime int  `json:"create_time,omitempty"`
	UpdateTime int  `json:"update_time,omitempty"`
}

Route apisix service object definition

type Service

type Service struct {
	ID         string                 `json:"id"`
	Name       string                 `json:"name,omitempty"`
	Upstream   *Upstream              `json:"upstream,omitempty"`
	UpstreamID string                 `json:"upstream_id,omitempty"`
	Plugins    map[string]interface{} `json:"plugins,omitempty"`
	Labels     map[string]string      `json:"labels,omitempty"`
	Websocket  bool                   `json:"enable_websocket,omitempty"`
	CreateTime int                    `json:"create_time,omitempty"`
	UpdateTime int                    `json:"update_time,omitempty"`
}

Service apisix service object definition

type Timeout

type Timeout struct {
	Connect int `json:"connect"`
	Send    int `json:"send"`
	Read    int `json:"read"`
}

Timeout definition for proxy

type Upstream

type Upstream struct {
	ID   string `json:"id"`
	Name string `json:"name,omitempty"`
	//roundrobin or chash
	Type string `json:"type"`
	//backend info, format like ip:port
	Nodes   map[string]int `json:"nodes"`
	Retries int            `json:"retries,omitempty"`
	//Checks  HealthCheck `json:"checks,omitempty"`
	Key          string            `json:"key,omitempty"`
	Timeout      *Timeout          `json:"timeout,omitempty"`
	HashOn       string            `json:"hash_on,omitempty"`
	PassHost     string            `json:"pass_host,omitempty"`
	UpstreamHost string            `json:"upstream_host,omitempty"`
	Labels       map[string]string `json:"labels,omitempty"`
	CreateTime   int               `json:"create_time,omitempty"`
	UpdateTime   int               `json:"update_time,omitempty"`
}

Upstream apisix upstream object definition

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL