services

package
v0.0.0-...-6217932 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: GPL-3.0 Imports: 4 Imported by: 0

README

Internal Services Implementation
--------------------------------

Every service has an interface and an implementation. Interfaces are
defined in the ``djrandom/services`` package, while the implementations
are contained in subdirectories. Every implementation must define a
client type that users of the service can instantiate, and it will
usually provide a server implementation.

Distributed services implement the PartitionedService defined in the
'djrandom/partition' package, which allows a very basic distributed
(partitioned) behavior based on a single primary key structure (with
rebalancing after partition changes).

Each implementation is RPC-based, it has a ``client.go`` file that
contains the client, and a ``service.go`` (and other files) that
define the server side. The only odd service is the database, where
``database.go`` actually holds the high-level database logic, which is
independent of the underlying key/value db implementation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	NewSession() (Session, error)

	Get(Session, string, string, interface{}) error
	Put(Session, string, string, interface{}) error
	Del(Session, string, string) error

	GetSong(Session, api.SongID) (*api.Song, bool)
	GetSongWithoutDupes(Session, api.SongID) (*api.Song, bool)
	PutSong(Session, *api.Song) error

	GetSongFingerprint(Session, api.SongID) (*api.Fingerprint, error)
	PutSongFingerprint(Session, api.SongID, *api.Fingerprint) error

	GetSongAcousticData(Session, *api.Song) (*api.AcousticData, error)
	PutSongAcousticData(Session, *api.Song, *api.AcousticData) error
	GetSongAcousticCorrelation(Session, api.SongID, api.SongID) (float32, error)
	GetSongAcousticCorrelations(Session, api.SongID) ([]api.AcousticCorrelation, error)
	PutSongAcousticCorrelation(Session, api.SongID, api.SongID, float32) error

	GetAudioFile(Session, string) (*api.AudioFile, bool)
	PutAudioFile(Session, *api.AudioFile) error

	GetUser(Session, string) (*api.User, bool)
	PutUser(Session, *api.User) error
	GetAuthKey(Session, string) (*api.AuthKey, bool)
	PutAuthKey(Session, *api.AuthKey) error

	AppendPlayLog(Session, *api.PlayLogEntry) error
	GetPlayLog(Session, string) (*api.PlayLogEntry, bool)

	GetMarkovMap(Session, string) (*api.MarkovMap, bool)
	PutMarkovMap(Session, string, *api.MarkovMap) error

	GetArtists(Session, string) ([]string, error)
}

Database is the high-level interface to the database layer.

type DatabaseClient

type DatabaseClient interface {
	NewSession() (Session, error)
}

DatabaseClient is the low-level interface to a database client.

type Index

type Index interface {
	AddDoc(id api.SongID, doc api.Document) error
	DeleteDoc(id api.SongID) error
	Search(query string) api.SongSet
	Scan() []api.SongID
}

Index is the client interface to the indexing service.

type Iterator

type Iterator interface {
	Next(interface{}) (string, error)
}

Generic interface for a database client iterator.

type Session

type Session interface {
	Get(bucket, key string, obj interface{}) error
	Put(bucket, key string, obj interface{}) error
	Del(bucket, key string) error
	Scan(bucket, startKey, endKey string, limit int) (Iterator, error)
	ScanKeys(bucket, startKey, endKey string, limit int) (Iterator, error)
	Close()
}

Session represents a database session. Whether this can be associated with a transaction or not is something that depends on the implementation.

type Storage

type Storage interface {
	GetUrl(key, mode string) string
	Write(key string, r io.Reader) error
	Open(key string) (io.ReadCloser, error)
	ReverseProxyDirector() func(string, *http.Request)
}

Storage is the client interface to the storage service.

type TaskClient

type TaskClient interface {
	Poll(fn func(*task_api.Job))
	Push(string) error
	PutJob(*task_api.Job) error
	GetJob(string) (*task_api.Job, error)
	CreateJob(*task_api.Plan, string) error
}

TaskClient exports the services of the global task queue.

Directories

Path Synopsis
client
The database service consists of a set of high-level operations built on top of a simple key/value store.
The database service consists of a set of high-level operations built on top of a simple key/value store.
The index package implements a distributed search index.
The index package implements a distributed search index.
The storage package implements a simple distributed blob store.
The storage package implements a simple distributed blob store.
A persistent task queue server.
A persistent task queue server.
task_requeue
Re-add orphaned tasks to the task_queue.
Re-add orphaned tasks to the task_queue.

Jump to

Keyboard shortcuts

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