vault: github.com/hashicorp/vault/command/agent/cache Index | Files | Directories

package cache

import "github.com/hashicorp/vault/command/agent/cache"

Index

Package Files

api_proxy.go handler.go lease_cache.go listener.go proxy.go testing.go

func Handler Uses

func Handler(ctx context.Context, logger hclog.Logger, proxier Proxier, inmemSink sink.Sink) http.Handler

func StartListener Uses

func StartListener(lnConfig *config.Listener) (net.Listener, *tls.Config, error)

type APIProxy Uses

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

APIProxy is an implementation of the proxier interface that is used to forward the request to Vault and get the response.

func (*APIProxy) Send Uses

func (ap *APIProxy) Send(ctx context.Context, req *SendRequest) (*SendResponse, error)

type APIProxyConfig Uses

type APIProxyConfig struct {
    Client *api.Client
    Logger hclog.Logger
}

type CacheMeta Uses

type CacheMeta struct {
    Hit bool
    Age time.Duration
}

CacheMeta contains metadata information about the response, such as whether it was a cache hit or miss, and the age of the cached entry.

type LeaseCache Uses

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

LeaseCache is an implementation of Proxier that handles the caching of responses. It passes the incoming request to an underlying Proxier implementation.

func NewLeaseCache Uses

func NewLeaseCache(conf *LeaseCacheConfig) (*LeaseCache, error)

NewLeaseCache creates a new instance of a LeaseCache.

func (*LeaseCache) HandleCacheClear Uses

func (c *LeaseCache) HandleCacheClear(ctx context.Context) http.Handler

HandleCacheClear returns a handlerFunc that can perform cache clearing operations.

func (*LeaseCache) RegisterAutoAuthToken Uses

func (c *LeaseCache) RegisterAutoAuthToken(token string) error

RegisterAutoAuthToken adds the provided auto-token into the cache. This is primarily used to register the auto-auth token and should only be called within a sink's WriteToken func.

func (*LeaseCache) Send Uses

func (c *LeaseCache) Send(ctx context.Context, req *SendRequest) (*SendResponse, error)

Send performs a cache lookup on the incoming request. If it's a cache hit, it will return the cached response, otherwise it will delegate to the underlying Proxier and cache the received response.

type LeaseCacheConfig Uses

type LeaseCacheConfig struct {
    Client      *api.Client
    BaseContext context.Context
    Proxier     Proxier
    Logger      hclog.Logger
}

LeaseCacheConfig is the configuration for initializing a new Lease.

type Proxier Uses

type Proxier interface {
    Send(ctx context.Context, req *SendRequest) (*SendResponse, error)
}

Proxier is the interface implemented by different components that are responsible for performing specific tasks, such as caching and proxying. All these tasks combined together would serve the request received by the agent.

func NewAPIProxy Uses

func NewAPIProxy(config *APIProxyConfig) (Proxier, error)

type SendRequest Uses

type SendRequest struct {
    Token   string
    Request *http.Request

    // RequestBody is the stored body bytes from Request.Body. It is set here to
    // avoid reading and re-setting the stream multiple times.
    RequestBody []byte
}

SendRequest is the input for Proxier.Send.

type SendResponse Uses

type SendResponse struct {
    Response *api.Response

    // ResponseBody is the stored body bytes from Response.Body. It is set here to
    // avoid reading and re-setting the stream multiple times.
    ResponseBody []byte
    CacheMeta    *CacheMeta
}

SendResponse is the output from Proxier.Send.

func NewSendResponse Uses

func NewSendResponse(apiResponse *api.Response, responseBody []byte) (*SendResponse, error)

NewSendResponse creates a new SendResponse and takes care of initializing its fields properly.

Directories

PathSynopsis
cachememdb

Package cache imports 30 packages (graph) and is imported by 2 packages. Updated 2019-07-18. Refresh now. Tools for package owners.