Documentation ¶
Overview ¶
Package etcd implements a DataClient for reading the skipper route definitions from an etcd service.
(See the DataClient interface in the skipper/routing package.)
etcd is a generic, distributed configuration service: https://github.com/coreos/etcd. The route definitions are stored under individual keys as eskip route expressions. When loaded from etcd, the routes will get the etcd key as id.
In addition to the DataClient implementation, type Client provides methods to Upsert and Delete routes.
Example ¶
package main import ( "github.com/zalando/skipper/etcd" "github.com/zalando/skipper/filters/builtin" "github.com/zalando/skipper/proxy" "github.com/zalando/skipper/routing" "log" ) func main() { // create etcd data client: dataClient, err := etcd.New(etcd.Options{ Endpoints: []string{"https://etcd.example.org"}, Prefix: "/skipper", Timeout: 0, Insecure: false, }) if err != nil { log.Fatal(err) } // create routing object: rt := routing.New(routing.Options{ FilterRegistry: builtin.MakeRegistry(), DataClients: []routing.DataClient{dataClient}}) defer rt.Close() // create http.Handler: p := proxy.New(rt, proxy.OptionsNone) defer p.Close() }
Output:
Index ¶
- type Client
- func (c *Client) Delete(id string) error
- func (c *Client) DeleteAllIf(routes []*eskip.Route, cond eskip.RoutePredicate) error
- func (c *Client) LoadAll() ([]*eskip.Route, error)
- func (c *Client) LoadAndParseAll() ([]*eskip.RouteInfo, error)
- func (c *Client) LoadUpdate() ([]*eskip.Route, []string, error)
- func (c *Client) Upsert(r *eskip.Route) error
- func (c *Client) UpsertAll(routes []*eskip.Route) error
- type Options
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is used to load the whole set of routes and the updates from an etcd store.
func (*Client) DeleteAllIf ¶
func (*Client) LoadAndParseAll ¶
Returns all the route definitions currently stored in etcd, or the parsing error in case of failure.
func (*Client) LoadUpdate ¶
Returns the updates (upserts and deletes) since the last initial request or update.
It uses etcd's watch functionality that results in blocking this call until the next change is detected in etcd or reaches the configured hard timeout.
type Options ¶
type Options struct { // A slice of etcd endpoint addresses. // (Schema and host.) Endpoints []string // Etcd path to a directory where the // Skipper related settings are stored. Prefix string // A timeout value for etcd long-polling. // The default timeout is 1 second. Timeout time.Duration // Skip TLS certificate check. Insecure bool // Optional OAuth-Token OAuthToken string // Optional username for basic auth Username string // Optional password for basic auth Password string }
Initialization options.