server

package
v0.0.0-...-e545f54 Latest Latest
Warning

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

Go to latest
Published: May 6, 2014 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package server provides web and rpc interfaces to DVID operations. It is also the likely package to manage polyglot persistence, i.e., given a data type and UUID, direct it to the appropriate storage engine (datastore service).

For a DVID web console, see the repo:

https://github.com/janelia-flyem/dvid-webclient

The goal of a DVID web console is to provide a GUI for monitoring and performing a subset of operations in a nicely formatted view.

DVID command line interaction occurs via the rpc interface to a running server. Please see the main DVID documentation:

http://godoc.org/github.com/janelia-flyem/dvid

Index

Constants

View Source
const (
	// The default URL of the DVID web server
	DefaultWebAddress = "localhost:8000"

	// The default RPC address of the DVID RPC server
	DefaultRPCAddress = "localhost:8001"

	// WebAPIVersion is the string version of the API.  Once DVID is somewhat stable,
	// this will be "v1/", "v2/", etc.
	WebAPIVersion = ""

	// The relative URL path to our Level 2 REST API
	WebAPIPath = "/api/" + WebAPIVersion

	// The name of the server error log, stored in the datastore directory.
	ErrorLogFilename = "dvid-errors.log"
)
View Source
const RPCHelpMessage = `` /* 526-byte string literal not displayed */
View Source
const WebHelp = `` /* 2249-byte string literal not displayed */

Variables

View Source
var (

	// ActiveHandlers is maximum number of active handlers over last second.
	ActiveHandlers int

	// MaxChunkHandlers sets the maximum number of chunk handlers (goroutines) that
	// can be multiplexed onto available cores.  (See -numcpu setting in dvid.go)
	MaxChunkHandlers = runtime.NumCPU()

	// HandlerToken is buffered channel to limit spawning of goroutines.
	// See ProcessChunk() in datatype/voxels for example.
	HandlerToken = make(chan int, MaxChunkHandlers)

	// SpawnGoroutineMutex is a global lock for compute-intense processes that want to
	// spawn goroutines that consume handler tokens.  This lets processes capture most
	// if not all available handler tokens in a FIFO basis rather than have multiple
	// concurrent requests launch a few goroutines each.
	SpawnGoroutineMutex sync.Mutex

	// Timeout in seconds for waiting to open a datastore for exclusive access.
	TimeoutSecs int
)

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, r *http.Request, message string)

func DatastoreService

func DatastoreService() *datastore.Service

DatastoreService returns the current datastore service. One DVID process is assigned to one datastore service, although it may be possible to have multiple (polyglot) persistence backends attached to that one service.

func DecodeJSON

func DecodeJSON(r *http.Request) (dvid.Config, error)

DecodeJSON decodes JSON passed in a request into a dvid.Config.

func MatchingUUID

func MatchingUUID(uuidStr string) (uuid dvid.UUID, err error)

MatchingUUID returns a UUID on this server that uniquely matches a uuid string.

func OrderedKeyValueDB

func OrderedKeyValueDB() (storage.OrderedKeyValueDB, error)

OrderedKeyValueDB returns the default key-value database

func OrderedKeyValueGetter

func OrderedKeyValueGetter() (storage.OrderedKeyValueGetter, error)

OrderedKeyValueGetter returns the default service for retrieving key-value pairs.

func OrderedKeyValueSetter

func OrderedKeyValueSetter() (storage.OrderedKeyValueSetter, error)

OrderedKeyValueSetter returns the default service for storing key-value pairs.

func Shutdown

func Shutdown()

Shutdown handles graceful cleanup of server functions before exiting DVID. This may not be so graceful if the chunk handler uses cgo since the interrupt may be caught during cgo execution.

func StorageEngine

func StorageEngine() (storage.Engine, error)

StorageEngine returns the default storage engine or nil if it's not available.

func VersionLocalID

func VersionLocalID(uuid dvid.UUID) (dvid.VersionLocalID, error)

VersionLocalID returns a server-specific local ID for the node with the given UUID.

Types

type Client

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

Client provides RPC access to a DVID server.

func NewClient

func NewClient(rpcAddress string) *Client

NewClient returns an RPC client to the given address.

func (*Client) Send

func (c *Client) Send(request datastore.Request) error

Send transmits an RPC command if a server is available.

type RPCConnection

type RPCConnection struct{}

RPCConnection will export all of its functions for rpc access.

func (*RPCConnection) Do

Do acts as a switchboard for remote command execution

type Service

type Service struct {
	// The currently opened DVID datastore
	*datastore.Service

	// Error log directory
	ErrorLogDir string

	// The address of the web server
	WebAddress string

	// The path to the DVID web client
	WebClientPath string

	// The address of the rpc server
	RPCAddress string
}

Service holds information on the servers attached to a DVID datastore. If more than one storage engine is used by a DVID server, e.g., polyglot persistence where graphs are managed by a graph database and key-value by a key-value database, this would be the level at which the storage engines are integrated.

func OpenDatastore

func OpenDatastore(datastorePath string) (service *Service, err error)

OpenDatastore returns a Server service. Only one datastore can be opened for any server.

func (*Service) Serve

func (service *Service) Serve(webAddress, webClientDir, rpcAddress string) error

Serve opens a datastore then creates both web and rpc servers for the datastore. This function must be called for DatastoreService() to be non-nil.

func (*Service) ServeHttp

func (service *Service) ServeHttp(address, clientDir string)

Listen and serve HTTP requests using address and don't let stay-alive connections hog goroutines for more than an hour. See for discussion: http://stackoverflow.com/questions/10971800/golang-http-server-leaving-open-goroutines

func (*Service) ServeRpc

func (service *Service) ServeRpc(address string) error

Listen and serve RPC requests using address.

Jump to

Keyboard shortcuts

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