api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RuleAny denotes any rule type
	RuleAny = iota

	// RuleRoute denotes rules with a routing field
	RuleRoute

	// RuleAction denotes rules with an action field
	RuleAction
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Action      string   `json:"action" yaml:"action"`
	Duration    float64  `json:"duration,omitempty" yaml:"duration,omitempty"`
	Probability float64  `json:"probability,omitempty" yaml:"probability,omitempty"`
	Tags        []string `json:"tags,omitempty" yaml:"tags,omitempty"`
	ReturnCode  int      `json:"return_code,omitempty" yaml:"return_code,omitempty"`
	LogKey      string   `json:"log_key,omitempty" yaml:"log_key,omitempty"`
	LogValue    string   `json:"log_value,omitempty" yaml:"log_value,omitempty"`
}

Action definition

type Backend

type Backend struct {
	Name       string      `json:"name,omitempty" yaml:"name,omitempty"`
	Tags       []string    `json:"tags" yaml:"tags"`
	Weight     float64     `json:"weight,omitempty" yaml:"weight,omitempty"`
	Resilience *Resilience `json:"resilience,omitempty" yaml:"resilience,omitempty"`
	LbType     string      `json:"lb_type,omitempty" yaml:"lb_type,omitempty"`
}

Backend represents a backend to route to.

type Match

type Match struct {
	Source  *Source           `json:"source,omitempty" yaml:"source,omitempty"`
	Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"`
}

Match definition

type Resilience

type Resilience struct {
	MaxConnections           int     `json:"max_connections,omitempty" yaml:"max_connections,omitempty"`
	MaxPendingRequest        int     `json:"max_pending_requests,omitempty" yaml:"max_pending_requests,omitempty"`
	MaxRequests              int     `json:"max_requests,omitempty" yaml:"max_requests,omitempty"`
	SleepWindow              float64 `json:"sleep_window,omitempty" yaml:"sleep_window,omitempty"`
	ConsecutiveErrors        int     `json:"consecutive_errors,omitempty" yaml:"consecutive_errors,omitempty"`
	DetectionInterval        float64 `json:"detection_interval,omitempty" yaml:"detection_interval,omitempty"`
	MaxRequestsPerConnection int     `json:"max_requests_per_connection,omitempty" yaml:"max_requests_per_connection,omitempty"`
}

Resilience cluster level circuit breaker options

type Route

type Route struct {
	Backends       []Backend `json:"backends" yaml:"backends"`
	URI            *URI      `json:"uri,omitempty" yaml:"uri,omitempty"`
	HTTPReqTimeout float64   `json:"http_req_timeout,omitempty" yaml:"http_req_timeout,omitempty"`
	HTTPReqRetries int       `json:"http_req_retries,omitempty" yaml:"http_req_retries,omitempty"`
}

Route definition

type Rule

type Rule struct {
	ID          string   `json:"id,omitempty" yaml:"id,omitempty"`
	Priority    int      `json:"priority,omitempty" yaml:"priority,omitempty"`
	Tags        []string `json:"tags,omitempty" yaml:"tags,omitempty"`
	Destination string   `json:"destination,omitempty" yaml:"destination,omitempty"`
	Match       *Match   `json:"match,omitempty" yaml:"match,omitempty"`
	Route       *Route   `json:"route,omitempty" yaml:"route,omitempty"`
	Actions     []Action `json:"actions,omitempty" yaml:"actions,omitempty"`
}

Rule represents an individual rule.

type RuleFilter

type RuleFilter struct {
	// IDs is the set of acceptable rule IDs. A rule will pass the filter if its ID is a member of this set.
	// This field is ignored when len(IDs) <= 0.
	IDs []string

	// Tags is the set of tags each rule must contain. A rule will pass the filter if its tags are a subset of this
	// set. This field is ignored when len(Tags) <= 0.
	Tags []string

	// Destinations is the set of acceptable rule destinations. A rule will pass the filter if its destination is
	// a member of this set. This field is ignored when len(Destinations) <= 0.
	Destinations []string

	// RuleType is the type of rule to filter by.
	RuleType int
}

RuleFilter to apply to sets of rules.

func (*RuleFilter) Apply

func (f *RuleFilter) Apply(rules []Rule) []Rule

Apply the filter to the given rules, and produce a new list of rules that satisfy the filter.

func (*RuleFilter) Empty

func (f *RuleFilter) Empty() bool

Empty returns whether the filter has any attributes that would cause rules to be filtered out. A filter is considered empty if no rules would be filtered out from any set of rules.

func (*RuleFilter) String

func (f *RuleFilter) String() string

String representation of the filter

type RulesByService

type RulesByService struct {
	Services map[string][]Rule `json:"services" yaml:"services"`
}

RulesByService definition

type RulesIDList

type RulesIDList struct {
	IDs []string `json:"ids" yaml:"ids"`
}

RulesIDList definition

type RulesService

type RulesService interface {
	// ListRules returns the rules that match the filter.
	ListRules(f *RuleFilter) (*RulesSet, error)
}

RulesService defines the interface used for rules service

type RulesSet

type RulesSet struct {
	// Rules that matched the filter.
	Rules []Rule `json:"rules"`

	// Revision of the rules for this namespace.
	Revision int64 `json:"revision"`
}

RulesSet is the information returned from a rule query.

type ServiceDiscovery

type ServiceDiscovery interface {

	// ListServices queries for the list of services for which instances are currently registered.
	ListServices() ([]string, error)

	// ListInstances queries for the list of service instances currently registered.
	ListInstances() ([]*ServiceInstance, error)

	// ListServiceInstances queries for the list of service instances currently registered for the given service.
	ListServiceInstances(serviceName string) ([]*ServiceInstance, error)
}

ServiceDiscovery defines the interface used for discovering service instances.

type ServiceEndpoint

type ServiceEndpoint struct {

	// Type is the endpoint's type, normally a protocol name, like "http", "https", "tcp", or "udp".
	Type string `json:"type"`

	// Value is the endpoint's value according to its type,
	// e.g. "172.135.10.1:8080" or "http://myapp.ng.bluemix.net/api/v1".
	Value string `json:"value"`
}

ServiceEndpoint describes a network endpoint of a service.

type ServiceInstance

type ServiceInstance struct {

	// ID is the unique ID assigned to this service instance.
	ID string `json:"id,omitempty"`

	// ServiceName is the name of the service being provided by this service instance.
	ServiceName string `json:"service_name,omitempty"`

	// Endpoint is the network endpoint of this service instance.
	Endpoint ServiceEndpoint `json:"endpoint,omitempty"`

	// Status is a string representing the status of the service instance.
	Status string `json:"status,omitempty"`

	// Tags is a set of arbitrary tags attached to this service instance.
	Tags []string `json:"tags,omitempty"`

	// Metadata is a marshaled JSON value (object, string, ...) associated with this service instance, in encoded-form.
	Metadata json.RawMessage `json:"metadata,omitempty"`

	// TTL is the time-to-live associated with this service instance, specified in seconds.
	TTL int `json:"ttl,omitempty"`

	// LastHeartbeat is the timestamp in which heartbeat has been last received for this service instance.
	LastHeartbeat time.Time `json:"last_heartbeat,omitempty"`
}

ServiceInstance describes an instance of a service.

type ServiceRegistry

type ServiceRegistry interface {

	// Register adds a service instance, described by the given ServiceInstance structure, to the registry.
	Register(instance *ServiceInstance) (*ServiceInstance, error)

	// Deregister removes a registered service instance, identified by the given ID, from the registry.
	Deregister(id string) error

	// Renew sends a heartbeat for the service instance identified by the given ID.
	Renew(id string) error
}

ServiceRegistry defines the interface used for registering service instances.

type Source

type Source struct {
	Name string   `json:"name" yaml:"name"`
	Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
}

Source definition.

type URI

type URI struct {
	Path          string `json:"path" yaml:"path"`
	Prefix        string `json:"prefix" yaml:"prefix"`
	PrefixRewrite string `json:"prefix_rewrite" yaml:"prefix_rewrite"`
}

URI for backends.

type Validator

type Validator interface {
	Validate(Rule) error
}

Validator validates rules against the rule schema.

func NewValidator

func NewValidator() (Validator, error)

NewValidator returns a new Validator.

Jump to

Keyboard shortcuts

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