bridge

package
v0.0.0-...-9d69390 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2015 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_API_INTERFACE = "127.0.0.1"
	DEFAULT_API_PORT      = "8989"
	DEFAULT_API_BINDING   = DEFAULT_API_INTERFACE + ":" + DEFAULT_API_PORT
	SESSION_REQUEST       = "sess_request"
	SESSION_HIJACKED      = "sess_hijacked"
)
View Source
const (
	SUBSCRIPTION_MIN_ID = 32
)

Variables

View Source
var (
	RequestHeaders = []string{"User-Agent", "Content-Type", "Accept", "Host", "Upgrade"}
)

Functions

This section is empty.

Types

type API

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

The REST API for processing dynamic hook registration

func NewAPI

func NewAPI(bridge Bridge) (*API, error)

Create a new API service

bridge:		the reference to the bridge itself

type Bridge

type Bridge interface {
	// retrieve the confir
	Config() *Config
	// a hook event
	HookEvent(string, string, []byte) error
	// hand back a list of subscriptions
	Subscriptions() []*client.Subscription
	// add a new subscription
	AddSubscription(*client.Subscription) (string, error)
	// remove a subscription from the bridge
	DeleteSubscription(string) error
	// shutdown and release the resources
	Close() error
}

The Bridge act as a hook the the API, as requests a passed through the chain, the bridge is called to see if anyone is listening to the API hook, forwards it on, hands back the mutated resource and allows it to continue;

func NewBridge

func NewBridge(cfg *Config) (Bridge, error)

Create a new Bridge from the configuration

cfg:		the bridge configuration reference

type BridgeImpl

type BridgeImpl struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

the bridge implementation

func (*BridgeImpl) AddSubscription

func (b *BridgeImpl) AddSubscription(subscription *client.Subscription) (string, error)

Add a new subscription to the bridge

subscription:		a pointer to the Subscription

func (*BridgeImpl) Close

func (b *BridgeImpl) Close() error

Close and release any resource being used by the bride

func (*BridgeImpl) Config

func (b *BridgeImpl) Config() *Config

Return a pointer to the configuration

func (*BridgeImpl) DeleteSubscription

func (b *BridgeImpl) DeleteSubscription(ID string) error

Remove the subscription from the bridge

id:			the subscription id which was given on subscribe()

func (*BridgeImpl) HookEvent

func (b *BridgeImpl) HookEvent(uri, event_type string, request []byte) error

func (*BridgeImpl) Subscriptions

func (b *BridgeImpl) Subscriptions() []*client.Subscription

Retrieve the current subscriptions which are in the bridge

type Config

type Config struct {
	// the interface spec the admin api bind to
	Bind string `json:"bind"`
	// the token used to authenticate
	Token string `json:"token"`
	// a map of the registrations
	Subscriptions []*client.Subscription `json:"subscriptions"`
	// an array of source and sinks -H tcp://0.0.0.0:3000,unix://var/run/docker.sock
	Pipes []string `json:"pipes"`
	// the verbose level
	Verbosity int `json:"verbose"`
}

the configuration for the bridge

func DefaultConfig

func DefaultConfig() *Config

Returns a default configuration

func LoadConfig

func LoadConfig(filename string) (*Config, error)

Load the configuration for the bridge from the config file

filename:		the full path to the configuration file

func (Config) String

func (r Config) String() string

type Pipe

type Pipe interface {
	Close() error
}

an interface for the pipe

func NewPipe

func NewPipe(source, sink *url.URL, bridge Bridge) (Pipe, error)

type PipeImpl

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

A pipe is source and sink connection to the docker api i.e. create unix://var/run/docker.sock -> tcp://0.0.0.0:2375

func (*PipeImpl) Close

func (pipe *PipeImpl) Close() error

type Subscriber

type Subscriber struct {
	Location string
}

type Subscribers

type Subscribers struct {
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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