gear

package module
v0.0.0-...-0af3362 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2019 License: MIT Imports: 5 Imported by: 10

README

Janstun Gear Library

pipeline status coverage report

Contents

Behaviors

Messaging

  • Subscriber
  • Publisher
  • Async Broker
  • Applicant
  • Sync Broker
  • Pipeline

HTTP

  • Mux (Multiplexer)
  • Gateway

Stream

  • Basic
  • Client
  • Gateway

Persistence

  • Dictionary
  • Relational SQL
  • Documentor

Authentication

  • Basic
  • Key

Logging

  • Basic
  • Levelled

Inbox

  • Email
  • SMS

Outbox

  • Email
  • SMS

Usage

Examples

Todo

License

This software is licensed under the MIT license. © 2019 Janstun

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitClause

func LimitClause(limit, offset uint) (string, []interface{})

Types

type Applicant

type Applicant interface {
	Request(topic string, data []byte, timeout time.Duration) ([]byte, error)
}

type AsyncBroker

type AsyncBroker interface {
	Publisher
	Subscriber
}

Message Queue - Publish Subscribe service

type BasicAuthentication

type BasicAuthentication interface {
	BasicAuthenticate(username, password string) error
}

type Dictionary

type Dictionary interface {
	Put(key string, value interface{}) error
	Has(key string) bool
	Get(key string) interface{}
	Delete(key string) error
	GetDefault(key string, value interface{}) interface{}
}

Key/Value Storage

type DocAggregate

type DocAggregate interface {
	// TODO: Create(info *CollectionInfo) error
	Drop() error

	// TODO: EnsureIndex(index Index) error
	EnsureIndexKey(key ...string) error
	DropIndex(key ...string) error
	DropIndexName(name string) error

	Count() (n int, err error)
	Find(query interface{}) DocQuery
	FindId(id interface{}) DocQuery

	Insert(docs ...interface{}) error

	Update(selector interface{}, update interface{}) error
	UpdateId(id interface{}, update interface{}) error

	Remove(selector interface{}) error
	RemoveId(id interface{}) error
}

type DocDatabase

type DocDatabase interface {
	Aggregate(name string) DocAggregate
	FileStorage(prefix string) DocFileStorage
}

type DocFile

type DocFile interface {
	io.Reader
	io.Writer
	io.Closer
	io.Seeker

	Id() interface{}
	SetId(id interface{})

	Name() string
	SetName(name string)

	Size() int64

	ContentType() string
	SetContentType(ctype string)

	GetMeta(result interface{}) (err error)
	SetMeta(metadata interface{})

	MD5() string

	SetChunkSize(bytes int)

	UploadDate() time.Time
	SetUploadDate(t time.Time)

	Abort()
}

type DocFileStorage

type DocFileStorage interface {
	Create(name string) (DocFile, error)
	Open(name string) (DocFile, error)
	OpenId(id interface{}) (DocFile, error)
	Find(query interface{}) DocQuery
	Remove(name string) (err error)
	RemoveId(id interface{}) error
}

type DocQuery

type DocQuery interface {
	Count() (n int, err error)
	All(result interface{}) error
	// TODO: Apply(change Change, result interface{}) (info *ChangeInfo, err error)
	Update(update interface{}, result interface{}) (int, error)
	Batch(n int) DocQuery
	Distinct(key string, result interface{}) error
	One(result interface{}) error
	Limit(n int) DocQuery
	Skip(n int) DocQuery
	Prefetch(p float64) DocQuery
	Select(selector interface{}) DocQuery
	Sort(fields ...string) DocQuery
}

type Documentor

type Documentor interface {
	DB(name string) DocDatabase
	Close()
}

type EmailInbox

type EmailInbox interface {
	ReceiveEmail() (interface{}, error)
}

type EmailOutbox

type EmailOutbox interface {
	SendEmail(interface{}) error
}

type HttpGateway

type HttpGateway interface {
	HttpMux

	ListenAndServe() error
	ListenAndServeTLS() error
	Shutdown(ctx context.Context) error
}

type HttpMux

type HttpMux interface {
	Handle(pattern string, handler http.Handler)
}

func CombineHttpMuxes

func CombineHttpMuxes(muxes ...HttpMux) HttpMux

type KeyAuthentication

type KeyAuthentication interface {
	KeyAuthenticate(key string) error
}

type LevelledLogger

type LevelledLogger interface {
	Log(level LogLevel, format string, v ...interface{})
}

type LogLevel

type LogLevel byte
const (
	FATAL LogLevel = iota
	ERROR
	WARN
	INFO
	DEBUG
)

type Logger

type Logger interface {
	Log(format string, v ...interface{})
}

type Message

type Message struct {
	// Message subject which indicates the queue the message have to enqueue in
	Topic string

	// In case message have to be answered the receiver may use
	// `Reply` as topic to publish the answer
	Reply string

	// Message payload
	Data []byte
}

type Pipeline

type Pipeline interface {
	Push([]byte) error
	Pull() ([]byte, error)
}

Message Queue - Push Pull service

type Publisher

type Publisher interface {
	Publish(msg Message) error
}

type SmsInbox

type SmsInbox interface {
	ReceiveSms() (interface{}, error)
}

type SmsOutbox

type SmsOutbox interface {
	SendSms(interface{}) error
}

type Sql

type Sql interface {
	Begin() (*sql.Tx, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

type Stream

type Stream interface {
	Send(b []byte) error
	Receive() ([]byte, error)
}

type StreamClient

type StreamClient interface {
	Stream

	Connect() error
	Shutdown(ctx context.Context) error
}

type StreamGateway

type StreamGateway interface {
	Stream

	ListenAndServe() error
	ListenAndServeTLS() error
	Shutdown(ctx context.Context) error
}

type Subscriber

type Subscriber interface {
	Subscribe(topic string) (<-chan Message, error)
	Unsubscribe(topic string) error
}

type SyncBroker

type SyncBroker interface {
	Applicant
}

Message Queue - Request Reply service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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