service

package
v0.0.0-...-1b2fc92 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknowElementType is returned if an element does not implement a valid type.
	ErrUnknowElementType = errors.New("unknow element does not implement a valid type")
)

Functions

func DecoderFromJSON

func DecoderFromJSON(js json.RawMessage) (encoders.Decoder, error)

DecoderFromJSON builds a decoder from json.

func DeleterFromJSON

func DeleterFromJSON(js json.RawMessage) (rw.Deleter, error)

DeleterFromJSON builds a deleter from json.

func EncoderDecoderFromString

func EncoderDecoderFromString(str string) encoders.EncoderDecoder

EncoderDecoderFromString returns an encoders.EncoderDecoder from it's name.

func EncoderFromJSON

func EncoderFromJSON(js json.RawMessage) (encoders.Encoder, error)

EncoderFromJSON builds an encoder from json.

func GetElementType

func GetElementType(js json.RawMessage) (string, error)

GetElementType return a string representing the element type.

func RWDFromString

func RWDFromString(str string) rw.ReadWriteDeleter

RWDFromString returns a rw.ReadWriteDeleter from it's name.

func ReaderFromJSON

func ReaderFromJSON(js json.RawMessage) (rw.Reader, error)

ReaderFromJSON builds a reader from json.

func RouterFromConfig

func RouterFromConfig(config json.RawMessage, silent bool) *chi.Mux

RouterFromConfig setup a chi.Mux router from a json configuration.

func SetDeleteHandler

func SetDeleteHandler(r chi.Router, del rw.Deleter)

SetDeleteHandler sets a chi handler for a Deleter.

func SetHandler

func SetHandler(r *chi.Mux, d Definition)

SetHandler set the right handler in chi for the provoded ServiceDefinition.

func SetReadHandler

func SetReadHandler(r chi.Router, ops *ReadOperations)

SetReadHandler sets a chi handler for a Reader.

func SetWriteHandler

func SetWriteHandler(r chi.Router, ops *WriteOperations)

SetWriteHandler sets a chi router for a Writer.

func UnmarshalAndStart

func UnmarshalAndStart(s Startable, js json.RawMessage) error

UnmarshalAndStart unmarshals a Startable element and start it.

func WriterFromJSON

func WriterFromJSON(js json.RawMessage) (rw.Writer, error)

WriterFromJSON builds a writer from json.

Types

type Definition

type Definition struct {
	URL        string          `json:"url"`
	WriterPipe json.RawMessage `json:"writer,omitempty"`
	ReaderPipe json.RawMessage `json:"reader,omitempty"`
	Deleter    json.RawMessage `json:"deleter,omitempty"`
}

Definition defines a URL enpoint and at lease a either a Writer, a Reader or a Deleter.

func (*Definition) Error

func (d *Definition) Error(err error)

Error display the service url and the encountred error.

type ReadOperations

type ReadOperations struct {
	Steps []encoders.Decoder
	Input rw.Reader
}

ReadOperations represents the various steps and the input necessary to retrieve data.

func NewReadOperationsFromJSON

func NewReadOperationsFromJSON(js json.RawMessage) (*ReadOperations, error)

NewReadOperationsFromJSON builds a ReadOperations from json.

func (*ReadOperations) AddStep

func (ro *ReadOperations) AddStep(js json.RawMessage) error

AddStep add a step to a ReadOperations from a json.RawMessage.

func (*ReadOperations) SetPipe

func (ro *ReadOperations) SetPipe(p *pipe.Pipe) error

SetPipe adds the decoders to the pipe.

type Startable

type Startable interface {
	Start() error
}

Startable is an object that implements a Start() method. It'is used to start encoders and rws.

type WriteOperations

type WriteOperations struct {
	Steps  []interface{}
	Output rw.Writer
}

WriteOperations represents the various steps and the output necessary to write data.

func NewTeeFromJSON

func NewTeeFromJSON(js json.RawMessage) (*WriteOperations, error)

NewTeeFromJSON build a WriteOperations for a tee from json.

func NewWriteOperationsFromJSON

func NewWriteOperationsFromJSON(js json.RawMessage) (*WriteOperations, error)

NewWriteOperationsFromJSON builds a WriteOperations from json.

func (*WriteOperations) AddStep

func (wo *WriteOperations) AddStep(js json.RawMessage) error

AddStep add a step to a WriteOperations from a json.RawMessage.

func (*WriteOperations) SetPipe

func (wo *WriteOperations) SetPipe(p *pipe.Pipe, id string) error

SetPipe set the various encoders, tees and the writer.

type WriteResponse

type WriteResponse struct {
	ID       string `json:"id"`
	BytesIn  int64  `json:"bytes_in"`
	BytesOut int64  `json:"bytes_out"`
}

WriteResponse is returned as a json response on a sucessfull write.

Jump to

Keyboard shortcuts

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