gc

package
v1.0.1-0...-099a076 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2015 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHeaders = []string{"Content-Length"}

The default headers to forward to the upstream

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache() *Cache

func (*Cache) Build

func (c *Cache) Build(runtime *garnish.Runtime) error

func (*Cache) Grace

func (c *Cache) Grace(window time.Duration) *Cache

If a request is expired but within the grace window, the expired version will be returned. In a background job, the cache will be refreshed. Grace is effective at eliminating the thundering heard problem [1 minute]

func (*Cache) KeyLookup

func (c *Cache) KeyLookup(lookup garnish.CacheKeyLookup) *Cache

The function used to generate the primary and secondary cache keys This defaults use the URL for the primary key and the QueryString for the secondary key Having a separate primary and secondary cache key allows us to purge a group of values. For example: primary: /v1/users/32 secondary: "ext=json" and "ext=xml" We can purge all variations associated with /v1/users/32

func (*Cache) MaxSize

func (c *Cache) MaxSize(size int) *Cache

The maximum size, in bytes, to cache [104857600] (100MB)

func (*Cache) NoSaint

func (c *Cache) NoSaint() *Cache

Disable saint mode With saint mode, if the upstream returns a 5xx error and a cached response is available, the cached response will be returned regardless of how far expired it is. [saint is enabled by default]

func (*Cache) PurgeHandler

func (c *Cache) PurgeHandler(handler garnish.PurgeHandler) *Cache

The function which will handle purge requests No default is provided since some level of custom authorization should be done If the handler returns a response, the middleware chain is stopped and the specified response is returned. If the handler does not return a response, the chain continues. This makes it possible to purge the garnish cache while allowing the purge request to be sent to the upstream

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

Configuration

func Configure

func Configure() *Configuration

Create a configuration

func LoadConfig

func LoadConfig(path string) (*Configuration, error)

Loads configuration from a toml file

func LoadConfigMap

func LoadConfigMap(m map[string]interface{}) (*Configuration, error)

func LoadConfigTyped

func LoadConfigTyped(t typed.Typed) (*Configuration, error)

func (*Configuration) Address

func (c *Configuration) Address(address string) *Configuration

The address to listen on [:8080]

func (*Configuration) Build

func (c *Configuration) Build() (*garnish.Runtime, error)

Build a runtime object from the configuration, which can then be used to start garnish

func (*Configuration) BytePool

func (c *Configuration) BytePool(capacity, count uint32) *Configuration

The size of each buffer and the number of buffers to keep in a the pool Upstream replies with a content length which fit within the specified capacity wil perform better. The pool is also used for incoming requests with bodies. [65536, 64]

func (*Configuration) Cache

func (c *Configuration) Cache() *Cache

Enable and configure the cache middleware

func (*Configuration) Debug

func (c *Configuration) Debug() *Configuration

Enable debug-level logging

func (*Configuration) DnsTTL

func (c *Configuration) DnsTTL(ttl time.Duration) *Configuration

The default time to cache DNS lookups. Overwritable on a per-upstream basis Even a short value (1s) can help under heavy load [1 minute]

func (*Configuration) Fatal

func (c *Configuration) Fatal(response garnish.Response) *Configuration

The response to return for a 500 [garnish.Empty(500)]

func (*Configuration) Hydrate

func (c *Configuration) Hydrate(loader garnish.HydrateLoader) *Hydrate

Enable and configure the hydration middleware

func (*Configuration) Insert

func (c *Configuration) Insert(position MiddlewarePosition, name string, handler garnish.Middleware) *Configuration

func (*Configuration) Logger

func (c *Configuration) Logger(logger garnish.Logs) *Configuration

Specify a custom logger to use

func (*Configuration) NotFound

func (c *Configuration) NotFound(response garnish.Response) *Configuration

The response to return for a 404 [garnish.Empty(404)]

func (*Configuration) Route

func (c *Configuration) Route(name string) *Route

Configure your routes

func (*Configuration) Stats

func (c *Configuration) Stats() *Stats

Enable and configure the stats middleware

func (*Configuration) Tweaker

func (c *Configuration) Tweaker(tweaker garnish.RequestTweaker) *Configuration

The default function that is used to tweak the http.Request sent to the upstream Overwritable on a per-upstream basis [nul]

func (*Configuration) Upstream

func (c *Configuration) Upstream(name string) *Upstream

Configure upstreams

type Hydrate

type Hydrate struct {
	// contains filtered or unexported fields
}

func NewHydrate

func NewHydrate(loader garnish.HydrateLoader) *Hydrate

func (*Hydrate) Build

func (h *Hydrate) Build(runtime *garnish.Runtime) (*middlewares.Hydrate, error)

func (*Hydrate) Header

func (h *Hydrate) Header(name string) *Hydrate

The header to look for in the upstream response which identifies the hydrate field ["X-Hydrate"]

type MiddlewarePosition

type MiddlewarePosition int
const (
	BEFORE_STATS MiddlewarePosition = iota
	BEFORE_CACHE
	BEFORE_HYDRATE
	BEFORE_DISPATCH
)

type Route

type Route struct {
	// contains filtered or unexported fields
}

func (*Route) All

func (r *Route) All(path string) *Route

Register a route for all methods. Can be overwritten on a per-method basis by registering the method-specific route BEFORE specifying the All variant.

func (*Route) Build

func (r *Route) Build(runtime *garnish.Runtime) (*garnish.Route, error)

func (*Route) CacheKeyLookup

func (r *Route) CacheKeyLookup(lookup garnish.CacheKeyLookup) *Route

The function used to get the cache key for this route. (overwrites the global Cache's lookup)

func (*Route) CacheKeyLookupRef

func (r *Route) CacheKeyLookupRef(route string) *Route

Allows the route to reference another route's CacheKeyLookup (based on that route's name). Used by the file-based configuration; when configured programmatically, CacheKeyLookup should be used.

func (*Route) CacheTTL

func (r *Route) CacheTTL(ttl time.Duration) *Route

The amount of time to cachet his request. If not specified, the Cache-Control header will be used (including not caching private). A value < 0 disables the cache for this route

func (*Route) Delete

func (r *Route) Delete(path string) *Route

Register a route for requests issued with a DELETE

func (*Route) FlowHandler

func (r *Route) FlowHandler(handler garnish.Middleware) *Route

Specify the handler function

func (*Route) Get

func (r *Route) Get(path string) *Route

Register a route for requests issued with a GET

func (*Route) Handler

func (r *Route) Handler(handler garnish.Handler) *Route

Specify the handler function

func (*Route) Head

func (r *Route) Head(path string) *Route

Register a route for requests issued with a HEAD

func (*Route) Method

func (r *Route) Method(method string, path string) *Route

Register a route for the requested method + path

func (*Route) Options

func (r *Route) Options(path string) *Route

Register a route for requests issued with an OPTIONS

func (*Route) Patch

func (r *Route) Patch(path string) *Route

Register a route for requests issued with a PATCH

func (*Route) Post

func (r *Route) Post(path string) *Route

Register a route for requests issued with a POST

func (*Route) Purge

func (r *Route) Purge(path string) *Route

Register a route for requests issued with a PURGE

func (*Route) Put

func (r *Route) Put(path string) *Route

Register a route for requests issued with a PUT

func (*Route) Slow

func (r *Route) Slow(max time.Duration) *Route

The amount of time before this request is logged as a slow request (overwrites the global Stat's slow value)

func (*Route) Upstream

func (r *Route) Upstream(upstream string) *Route

Specify the name of the upstream.

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) Add

func (r *Router) Add(name string) *Route

func (*Router) Build

func (r *Router) Build(runtime *garnish.Runtime) error

type Stats

type Stats struct {
	// contains filtered or unexported fields
}

Configuration for the stats middleware

func NewStats

func NewStats() *Stats

func (*Stats) Build

func (s *Stats) Build(runtime *garnish.Runtime) error

In normal usage, there's no need to call this method. Builds the stats middleware into the runtime

func (*Stats) FileName

func (s *Stats) FileName(fileName string) *Stats

The file to save the statistics to. The file is overwritten on each write. ["stats.json"]

func (*Stats) Slow

func (s *Stats) Slow(slow time.Duration) *Stats

The default threshold to consider flag a request as being slow This can be overwritten on a per-route basis [250ms]

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

func (*Transport) KeepAlive

func (t *Transport) KeepAlive(count uint32) *Transport

the number of connections to keep alive. Set to 0 to disable [16]

type Upstream

type Upstream struct {
	// contains filtered or unexported fields
}

func (*Upstream) Address

func (u *Upstream) Address(address string) *Transport

the address to connect to. Should begin with unix:/ http:// or https:// [""]

func (*Upstream) Build

func (u *Upstream) Build(runtime *garnish.Runtime, tweaker garnish.RequestTweaker) (garnish.Upstream, error)

func (*Upstream) DnsCache

func (u *Upstream) DnsCache(duration time.Duration) *Upstream

the duration to cache the upstream's dns lookup. Set to 0 to prevent garnish from caching this value (even a few seconds can help) [1 minute]

func (*Upstream) Headers

func (u *Upstream) Headers(headers ...string) *Upstream

The headers to copy from the incoming request to the outgoing request [Content-Length]

func (*Upstream) Tweaker

func (u *Upstream) Tweaker(tweaker garnish.RequestTweaker) *Upstream

Custom callback to modify the request (out) that will get sent to the upstream

func (*Upstream) TweakerRef

func (u *Upstream) TweakerRef(upstream string) *Upstream

Allows the upstream to reference another upstream's tweaker (based on that upstream's name). Used by the file-based configuration; when configured programmatically, Tweaker should be used.

type Upstreams

type Upstreams struct {
	// contains filtered or unexported fields
}

func NewUpstreams

func NewUpstreams() *Upstreams

func (*Upstreams) Add

func (u *Upstreams) Add(name string) *Upstream

Used internally

func (*Upstreams) Build

func (u *Upstreams) Build(runtime *garnish.Runtime, defaultTweaker garnish.RequestTweaker) error

Jump to

Keyboard shortcuts

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