slashquery

package module
v0.0.0-...-6d259e4 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2017 License: BSD-3-Clause Imports: 14 Imported by: 0

README

SlashQuery

API Gateway

The big picture:

   (slashquery API Gateway)

api.example.com/<path endpoint>
               |            (plugins)       (upstream)      (microservices)
               |                                            /home
               | /*     >--[middleware]---[LoadBalancer]--< /home
               |                                            /home
               |
               |                                            /foo
               | /foo/* >--[middleware]---[LoadBalancer]--< /foo
               |                                            /foo
               |
               |                                            /foo-version-2
 (versioning)  | /foo/* >--[middleware]---[LoadBalancer]--< /foo-version-2
               |                                            /foo-version-2
               |
               |                                            /bar
               ` /bar/* >--[middleware]---[LoadBalancer]--< /bar
                                                            /bar

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Route

type Route struct {
	// URL of the upstream, if set, Scheme, Host, Path and Upstream
	// will be set from it,  the upstream will named has the host
	// after parsing the URL
	URL string

	// Scheme http or https
	Scheme string

	// Host hostname to use when doing the request
	Host string

	// Path to use when doing the request
	Path string

	// Upstream identifier to use
	Upstream string

	// Methods list of allowed methods, example: GET, POST, HEAD
	Methods []string

	// Plugins list of plugins to use (middleware)
	Plugins []string

	// Insecure is set to yes will skip the certificate verification
	Insecure bool

	// DisableKeepAlive if set to yes won't cache/reuse the connections
	DisableKeepAlive bool
	// contains filtered or unexported fields
}

Route define an upstream

type Servers

type Servers struct {
	Addresses []string
	Expire    time.Time
	// contains filtered or unexported fields
}

Servers keep IP's from upstreams (needs a resolver)

type Slashquery

type Slashquery struct {
	Config    map[string]string
	Plugins   map[string][]string
	Resolver  *resolver.Resolver
	Routes    map[string]*Route
	Servers   map[string]*Servers
	Upstreams map[string]*Upstream
}

Slashquery structure

func New

func New(file string) (*Slashquery, error)

New return a new slashquery instance

func (*Slashquery) Balancer

func (sq *Slashquery) Balancer(name, network, port string) (net.Conn, error)

Balancer round-robin the upstreams

func (*Slashquery) Debug

func (sq *Slashquery) Debug() bool

Debug enable/disable based on config["debug"] value

func (*Slashquery) Proxy

func (sq *Slashquery) Proxy(r string) *httputil.ReverseProxy

Proxy return instances of httputil.ReverseProxy

func (*Slashquery) ResolveUpstream

func (sq *Slashquery) ResolveUpstream(upstream string)

ResolveUpstream get IP's for specified upstream

func (*Slashquery) ResolveUpstreams

func (sq *Slashquery) ResolveUpstreams()

ResolveUpstreams get IP's of servers

func (*Slashquery) Setup

func (sq *Slashquery) Setup() error

Setup configures the upstream

type Upstream

type Upstream struct {
	Servers []string
	Timeout int
}

Upstream structure

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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