middleware

package
v0.0.0-...-301923a Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: BSD-3-Clause Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Drivers known to our middleware
	DriverGrpc = "grpc"
	DriverNats = "nats"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EndpointClient

type EndpointClient interface {
	// Connect to the server, given the middleware settings struct
	Connect(*Settings) error

	// Close connection(s) to the server
	Close() error

	// Send collection creation request, return new Id
	//   - Collection name is required to be unique among collections
	CreateCollection(*wyc.Collection) (string, error)

	// Send item creation request, return new Id
	// Required to include non empty fields for
	//   - parent (collection Id)
	//   - item type
	//   - item variant
	// Item facets are required to include
	//   - grandparent collection name
	CreateItem(*wyc.Item) (string, error)

	// Send version creation request, return new Id & new version number
	// Required to include non empty fields for
	//   - parent (item Id)
	// Version facets are required to include
	//   - grandparent collection name
	//   - parent item type
	//   - parent item variant
	CreateVersion(*wyc.Version) (string, int32, error)

	// Send resource creation request, return new Id
	// Required to include non empty fields for
	//   - parent (version Id)
	CreateResource(*wyc.Resource) (string, error)

	// Send link creation request, return new Id
	// Required to include non empty fields for
	//   - source Id
	//   - destination Id
	CreateLink(*wyc.Link) (string, error)

	// Given the Id, delete some collection
	DeleteCollection(string) error

	// Given the Id, delete some item
	DeleteItem(string) error

	// Given the Id, delete some version
	DeleteVersion(string) error

	// Given the Id, delete some resource
	DeleteResource(string) error

	// Given some list of QueryDescriptions, return matching collections
	FindCollections(int32, int32, []*wyc.QueryDesc) ([]*wyc.Collection, error)

	// Given some list of QueryDescriptions, return matching items
	FindItems(int32, int32, []*wyc.QueryDesc) ([]*wyc.Item, error)

	// Given some list of QueryDescriptions, return matching versions
	FindVersions(int32, int32, []*wyc.QueryDesc) ([]*wyc.Version, error)

	// Given some list of QueryDescriptions, return matching resources
	FindResources(int32, int32, []*wyc.QueryDesc) ([]*wyc.Resource, error)

	// Given some list of QueryDescriptions, return matching links
	FindLinks(int32, int32, []*wyc.QueryDesc) ([]*wyc.Link, error)

	// Given Id of some Item, return version marked as publish
	PublishedVersion(string) (*wyc.Version, error)

	// Given Id of some Version, mark version as publish
	//  - Only one version of a given Item is considered publish at a time
	SetPublishedVersion(string) error

	// Given Version Id update version facets with given facets
	UpdateVersionFacets(string, map[string]string) error

	// Given Item Id update item facets with given facets
	UpdateItemFacets(string, map[string]string) error

	// Given Collection Id update item facets with given facets
	UpdateCollectionFacets(string, map[string]string) error

	// Given Item Id update item facets with given facets
	UpdateResourceFacets(string, map[string]string) error

	// Given Item Id update item facets with given facets
	UpdateLinkFacets(string, map[string]string) error
}

Middleware client interface The client side needs to implement connecting to the server, and calling the appropriate middleware functions to send data across

func NewClient

func NewClient(driver string) (EndpointClient, error)

Create a new middleware client using the diver matching the given string

type EndpointServer

type EndpointServer interface {
	// Start up and serve client requests given some config string and
	// a reference to the main wysteria server's available functions
	ListenAndServe(*Settings, ServerHandler) error

	// Time is up, kill everything and shutdown the server, kill all connections
	Shutdown() error
}

The server side middleware needs to handle starting up, listening, shutting down and calling the appropriate handlers from the given server handler when listening

func NewServer

func NewServer(driver string) (EndpointServer, error)

Create a new middleware server using the diver matching the given string

type ServerHandler

type ServerHandler interface {
	// All funcs here as documented in EndpointClient. These are simply the entry points
	// for the middlware receiving the request(s) to call down into the main server
	// and business logic.
	CreateCollection(*wyc.Collection) (string, error)
	CreateItem(*wyc.Item) (string, error)
	CreateVersion(*wyc.Version) (string, int32, error)
	CreateResource(*wyc.Resource) (string, error)
	CreateLink(*wyc.Link) (string, error)

	DeleteCollection(string) error
	DeleteItem(string) error
	DeleteVersion(string) error
	DeleteResource(string) error

	FindCollections(int32, int32, []*wyc.QueryDesc) ([]*wyc.Collection, error)
	FindItems(int32, int32, []*wyc.QueryDesc) ([]*wyc.Item, error)
	FindVersions(int32, int32, []*wyc.QueryDesc) ([]*wyc.Version, error)
	FindResources(int32, int32, []*wyc.QueryDesc) ([]*wyc.Resource, error)
	FindLinks(int32, int32, []*wyc.QueryDesc) ([]*wyc.Link, error)

	PublishedVersion(string) (*wyc.Version, error)
	SetPublishedVersion(string) error

	UpdateVersionFacets(string, map[string]string) error
	UpdateItemFacets(string, map[string]string) error
	UpdateCollectionFacets(string, map[string]string) error
	UpdateResourceFacets(string, map[string]string) error
	UpdateLinkFacets(string, map[string]string) error
}

Implemented by the Wysteria Server

This is passed into the middleware server side endpoint as the 'ServerHandler'

type Settings

type Settings struct {
	Driver       string
	Config       string
	SSLCert      string
	SSLKey       string
	SSLEnableTLS bool
	SSLVerify    bool
}

Generic middleware settings struct, holding the diver name and the config string. Each driver will expect it's own kind of config string, depending on the driver.

func (*Settings) TLSconfig

func (s *Settings) TLSconfig() (*tls.Config, error)

Return TLS config for our middleware settings

Directories

Path Synopsis
Package wysteria_grpc is a generated protocol buffer package.
Package wysteria_grpc is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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