message

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2017 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package message provides wrapper structs and helper methods to pipe actual database documents throughout transporter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalData added in v0.1.2

func MarshalData(m Msg) ([]byte, error)

MarshalData attempts to call json.Marshal on the Msg.

func Register added in v0.1.2

func Register(name string, adaptor Adaptor)

Types

type Adaptor added in v0.1.2

type Adaptor interface {
	Name() string
	From(op ops.Op, namespace string, data data.Data) Msg
}

func MustUseAdaptor added in v0.1.2

func MustUseAdaptor(name string) Adaptor

func UseAdaptor added in v0.1.2

func UseAdaptor(name string) (Adaptor, error)

type Base added in v0.1.2

type Base struct {
	TS        int64
	NS        string
	Operation ops.Op
	MapData   data.Data
}

Base represents a standard message format for transporter data if it does not meet your need, you can embed the struct and override whatever methods needed to accurately represent the data structure.

func (*Base) Data added in v0.1.2

func (m *Base) Data() data.Data

Data returns the internal representation of the document as the data.Data type

func (*Base) ID added in v0.1.2

func (m *Base) ID() string

ID will attempt to convert the _id field into a string representation

func (*Base) Namespace added in v0.1.2

func (m *Base) Namespace() string

Namespace returns the combination of database/table/colleciton for the underlying adaptor.

func (*Base) OP added in v0.1.2

func (m *Base) OP() ops.Op

OP returns the type of operation the message is associated with (i.e. insert/update/delete).

func (*Base) Timestamp added in v0.1.2

func (m *Base) Timestamp() int64

Timestamp returns the time the object was created in transporter (i.e. it has no correlation with any time in the database).

type Commandable added in v0.1.2

type Commandable interface {
	Command(Msg) error
}

type Deletable added in v0.1.2

type Deletable interface {
	Delete(Msg) error
}

type Insertable added in v0.1.2

type Insertable interface {
	Insert(Msg) error
}

type Msg

type Msg interface {
	ID() string
	OP() ops.Op
	Timestamp() int64
	Data() data.Data
	Namespace() string
}

A Msg serves to wrap the actual document to provide additional metadata about the document being transported.

func Exec added in v0.1.2

func Exec(a Adaptor, m Msg) (Msg, error)

func From added in v0.1.2

func From(op ops.Op, namespace string, d data.Data) Msg

From builds a message.Msg specific to an elasticsearch document

type Updatable added in v0.1.2

type Updatable interface {
	Update(Msg) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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