lobby

package module
v0.0.0-...-466853b Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2018 License: MIT Imports: 3 Imported by: 0

README

Lobby

GoDoc Build Status Go Report Card

Lobby is an open-source pluggable platform for data delivery.

Overview

At the core, Lobby is a framework to assemble network APIs and backends. It provides several key features:

  • Topics: Applications can create topics they can use to save data using the API of their choice. A topic is bound to a particular backend, Lobby can route data to the right backend so applications can target multiple stores using different topics.
  • Protocol and backend agnostic: Data can be received using HTTP, gRPC, asynchronous consumers or by any other means and delivered to any database, message broker or even proxied to another service. Lobby provides a solid framework that links everything together.
  • Plugin based architecture: Lobby can be extended using plugins. New APIs and backends can be written using any language that supports gRPC.

How it works

Topic

Lobby uses a concept of Topic to store data. Each topic is associated to a specific backend and provide an unified API to send values.

Backend

A backend is the storage unit used by Lobby. It usually represents a datastore or a message broker but can litteraly be anything that satisfies the backend interface, like an http proxy, a file or a memory store. By default, Lobby is shipped with a builtin BoltDB backend and provides MongoDB and Redis backends as plugins.

Entrypoints

Lobby can run multiple servers at the same time, each providing a different entrypoint to manipulate topics. Those entrypoints can create and manipulate all or part of Lobby's topics. By default, Lobby runs an HTTP server and a gRPC server which is the main communication system, also used to communicate with plugins. NSQ is provided as a plugin.

Usage

Running Lobby:

lobby run

The previous command runs the gRPC server, the HTTP server and the BoltDB backend.

To run Lobby with plugins:

lobby run --server=nsq --backend=mongo --backend=redis

The previous command adds a NSQ consumer, a MongoDB and a Redis backend.

Currently, Lobby contains no topics.

The following command creates a topic with a Redis backend using the HTTP API:

curl -X POST -d '{"name": "quotes", "backend": "redis"}' http://localhost:5657/v1/topics

Once the topic is created, data can be sent to it.

The following command will send the following value in the quotes topic.

curl -X POST -d 'There is no blue without yellow and without orange.' \
                                  http://localhost:5657/v1/topics/quotes

Documentation

Index

Constants

View Source
const (
	ErrBackendNotFound    = Error("backend not found")
	ErrTopicNotFound      = Error("topic not found")
	ErrTopicAlreadyExists = Error("topic already exists")
)

Errors.

View Source
const Version = "v0.1.0-DEV"

Version represents the current build version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	// Get a topic by name.
	Topic(name string) (Topic, error)
	// Close the backend connection.
	Close() error
}

A Backend is able to create topics that can be used to store data.

type Error

type Error string

Error represents a Lobby error.

func (Error) Error

func (e Error) Error() string

Error returns the error message.

type Message

type Message struct {
	Group string
	Value []byte
}

A Message is a key value pair saved in a topic.

type Plugin

type Plugin interface {
	// Unique name of the plugin
	Name() string

	// Gracefully closes the plugin
	Close() error

	// Wait for the plugin to quit or crash. This is a blocking operation.
	Wait() error
}

Plugin is a generic lobby plugin.

type PrefixWriter

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

PrefixWriter is a writer that adds a prefix before every line.

func NewFuncPrefixWriter

func NewFuncPrefixWriter(prefixFn func() []byte, to io.Writer) *PrefixWriter

NewFuncPrefixWriter creates a PrefixWriter that uses a function to generate a prefix.

func NewPrefixWriter

func NewPrefixWriter(prefix string, to io.Writer) *PrefixWriter

NewPrefixWriter creates a PrefixWriter.

func (*PrefixWriter) Write

func (w *PrefixWriter) Write(p []byte) (int, error)

type Registry

type Registry interface {
	Backend

	// Register a backend under the given name.
	RegisterBackend(name string, backend Backend)
	// Create a topic and register it to the Registry.
	Create(backendName, topicName string) error
}

A Registry manages the topics, their configuration and their associated Backend.

type Server

type Server interface {
	// Name returns the server short description. e.g: "http", "grpc", etc.
	Name() string

	// Serve incoming requests. Must block.
	Serve(net.Listener) error

	// Stop gracefully stops the server.
	Stop() error
}

A Server serves incoming requests.

type Topic

type Topic interface {
	// Send a message in the topic.
	Send(*Message) error
	// Close the topic. Can be used to close sessions if required.
	Close() error
}

A Topic manages a collection of items.

func TopicFunc

func TopicFunc(fn func(*Message) error) Topic

TopicFunc creates a topic from a send function.

Directories

Path Synopsis
backend
nsq
boltpb
Package boltpb is a generated protocol buffer package.
Package boltpb is a generated protocol buffer package.
cli
app
cmd
etcdpb
Package etcdpb is a generated protocol buffer package.
Package etcdpb is a generated protocol buffer package.
rpc
proto
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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