server

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2016 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetUpAPIRouter

func SetUpAPIRouter(prefix string, router *web.Router, route func(prefix string, r *web.Router))

SetUpAPIRouter sets up a router for APIs with user defined custom route. Subrouters needs to have APIContext as their first field.

func SetUpContextAndRouter

func SetUpContextAndRouter(prefix string, jascoRoot *web.Router, gvariables *ContextGlobalVariables) (*web.Router, error)

SetUpContextAndRouter creates a router of the API server and its context. jascoRoot is a root router returned from jasco.New.

This function returns a new web.Router. Don't use the router returned from this function as a handler of HTTP server, but use jascoRoot instead.

Types

type APIContext

type APIContext struct {
	*Context
}

APIContext is a base context of all API controllers.

type Context

type Context struct {
	*jasco.Context
	// contains filtered or unexported fields
}

Context is a context object for gocraft/web.

func (*Context) SetTopologyRegistry

func (c *Context) SetTopologyRegistry(r TopologyRegistry)

SetTopologyRegistry sets the registry of topologies to this context. This method must be called in the middleware of Context.

type ContextGlobalVariables

type ContextGlobalVariables struct {
	// Logger is used to write log messages.
	Logger *logrus.Logger

	// LogDestination is a writer to which logs are written.
	LogDestination io.WriteCloser

	// Topologies is a registry which manages topologies to support multi
	// tenancy.
	Topologies TopologyRegistry

	// Config has configuration parameters.
	Config *config.Config
}

ContextGlobalVariables has fields which are shared through all contexts allocated for each request.

func SetUpContextGlobalVariables

func SetUpContextGlobalVariables(conf *config.Config) (*ContextGlobalVariables, error)

SetUpContextGlobalVariables create a new ContextGlobalVariables from a config. DO NOT make any change on the config after calling this function. The caller can change other members of ContextGlobalVariables.

The caller must Close LogDestination.

type TopologyRegistry

type TopologyRegistry interface {
	// Register registers a new topology. If the registry already has a
	// topology having the same name, this method fails and returns
	// os.ErrExist.
	Register(name string, tb *bql.TopologyBuilder) error

	// Lookup returns a topology having the name. It returns core.NotExistError
	// if it doesn't have the topology.
	Lookup(name string) (*bql.TopologyBuilder, error)

	// List returns all topologies the registry has. The caller can safely
	// modify the map returned from this method.
	List() (map[string]*bql.TopologyBuilder, error)

	// Unregister removes a creator from the registry. It returns a removed
	// topology. If the registry doesn't have a topology, it returns
	// core.NotExistError. If it failed to remove the topology, itreturns an error.
	//
	// Unregister doesn't stop the topology when it's removed. It's the caller's
	// responsibility to correctly stop it.
	Unregister(name string) (*bql.TopologyBuilder, error)
}

TopologyRegistry is a registry of topologies managed in th server.

func NewDefaultTopologyRegistry

func NewDefaultTopologyRegistry() TopologyRegistry

NewDefaultTopologyRegistry returns a default implementation of TopologyRegistry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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