server

package
v0.0.0-...-39cf20d Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a very simple indexed database implementation using LevelDB. Records can't be deleted. Any string value in the incoming message is indexed, which makes it possible to run simple key=value queries.

The database is organized as follows:

We only support exact key=value matches, so the index is modeled directly on top of leveldb primitives (scanning key ranges), which makes insertions really fast.

For every message, we generate a unique id, and we store it under messages/<id>. Then we extract all the indexable key/value pairs, and store the message id under index/<key>/<value>/<id> (yes, the id appears twice, it's part of the key just to ensure uniqueness).

Keys and values can be anything as long as they don't contain a null byte (which is used internally as the primary key separator).

func NewDB

func NewDB(path string, dbopts *DBOptions) *DB

Open a database at 'path' with the given options.

func (*DB) Close

func (db *DB) Close()

Close the database and release associated resources.

func (*DB) Dump

func (db *DB) Dump(w io.Writer) error

Dump contents to a writer.

func (*DB) Query

func (db *DB) Query(q map[string]string) ([]audit.Message, error)

Query the database and return the results.

func (*DB) Restore

func (db *DB) Restore(r io.Reader) error

Restore contents from a dump.

func (*DB) Write

func (db *DB) Write(msg audit.Message) error

Write a Message to the database.

type DBOptions

type DBOptions struct {
	LRUCacheSize       int
	BloomFilterSizeExp int
	ExcludedKeys       []string
}

Options for database creation.

type HttpServer

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

func NewHttpServer

func NewHttpServer(db *DB) *HttpServer

func (*HttpServer) ListenAndServeTLS

func (h *HttpServer) ListenAndServeTLS(addr, caFile, certFile, keyFile string) error

Start the server (with TLS).

Jump to

Keyboard shortcuts

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