translation

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommandGet         = "GET"
	CommandGetAttrs    = "GET_ATTRIBUTES"
	CommandSet         = "SET"
	CommandSetAttrs    = "SET_ATTRIBUTES"
	CommandTestSet     = "TEST_AND_SET"
	CommandAddRow      = "ADD_ROW"
	CommandDeleteRow   = "DELETE_ROW"
	CommandReplaceRows = "REPLACE_ROWS"

	HeaderWPASyncOldCID = "X-Webpa-Sync-Old-Cid"
	HeaderWPASyncNewCID = "X-Webpa-Sync-New-Cid"
	HeaderWPASyncCMC    = "X-Webpa-Sync-Cmc"
)

All the supported commands, WebPA Headers and misc

Variables

View Source
var (
	ErrEmptyNames        = common.NewBadRequestError(errors.New("names parameter is required"))
	ErrInvalidService    = common.NewBadRequestError(errors.New("unsupported Service"))
	ErrUnsupportedMethod = common.NewBadRequestError(errors.New("unsupported method. Could not decode request payload"))

	//Set command errors
	ErrInvalidSetWDMP = common.NewBadRequestError(errors.New("invalid SET message"))
	ErrNewCIDRequired = common.NewBadRequestError(errors.New("newCid is required for TEST_AND_SET"))

	//Add/Delete command  errors
	ErrMissingTable = common.NewBadRequestError(errors.New("table property is required"))
	ErrMissingRow   = common.NewBadRequestError(errors.New("row property is required"))
	ErrInvalidRow   = common.NewBadRequestError(errors.New("row property is invalid"))

	//Replace command error
	ErrMissingRows = common.NewBadRequestError(errors.New("rows property is required"))
	ErrInvalidRows = common.NewBadRequestError(errors.New("rows property is invalid"))
)

Error values definitions for the translation service

Functions

func ConfigHandler

func ConfigHandler(c *Options)

ConfigHandler sets up the server that powers the translation service

Types

type Options

type Options struct {
	S Service

	//APIRouter is assumed to be a subrouter with the API prefix path (i.e. 'api/v2')
	APIRouter *mux.Router

	Authenticate                *alice.Chain
	Log                         kitlog.Logger
	ValidServices               []string
	ReducedLoggingResponseCodes []int
}

Options wraps the properties needed to set up the translation server

type Service

type Service interface {
	SendWRP(context.Context, *wrp.Message, string) (*common.XmidtResponse, error)
}

Service represents the Webpa-Tr1d1um component that translates WDMP data into WRP which is compatible with the XMiDT API.

func NewService

func NewService(o *ServiceOptions) Service

NewService constructs a new translation service instance given some options.

type ServiceOptions

type ServiceOptions struct {
	//XmidtWrpURL is the URL of the XMiDT API which takes in WRP messages.
	XmidtWrpURL string

	//WRPSource is the value set on the WRPSource field of all WRP messages created by Tr1d1um.
	WRPSource string

	//Acquirer provides a mechanism to build auth headers for outbound requests.
	AuthAcquirer acquire.Acquirer

	//Tr1d1umTransactor is the component that's responsible to make the HTTP
	//request to the XMiDT API and return only data we care about.
	common.Tr1d1umTransactor
}

ServiceOptions defines the options needed to build a new translation WRP service.

Jump to

Keyboard shortcuts

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