sdk

package
v0.4.0 Latest Latest
Warning

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

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

README

Nitric Membrane SDK

The Nitric SDK is a collection of golang interfaces that are used to abstract services provided by Nitric.

Providers

Providers are a collection of plugin factories, these are compiled into Go plugins to be loaded by the pluggable memrane.

Example providers:

Gateway Plugin

Gateway plugins are used to abstract implementation detail for application input/output. This usually involves presenting some kind of external interface (for example a HTTP server), normalizing incoming data from this interface to pass to the hosted application (over HTTP) and then denormalizing output to be returned back to the hosted environment.

Official Gateway Plugins:

Eventing Plugin

Eventing plugins are used for communication between services, it exposes a simple publish model that allows NitricEvent(s) to be pushed onto topics. Topic subscriptions are normally defined at deploy time and configured through the Nitric Stack definition file.

Official Eventing Plugins:

KeyValue Plugin

KeyValue (KV) plugins are used to provide a key value store interface that allows users to store simple object data under a given collection and key.

Official KeyValue Plugins:

Queue Plugin

Queue plugins provide a simple push/pop interface allowing users to asynchronously process batch operations.

Official Queue Plugins:

Storage Plugin

Storage plugins provide access to provide blob stores, allowing storage of files using a simple bucket/key interface for storage and retrieval.

Official Storage Plugins:

Auth Plugin

Auth plugins allow for the creation and management of users and tenants as well as login/verification of users and their tokens.

Official Auth Plugins:

Documentation

Index

Constants

View Source
const MaxSubCollectionDepth int = 1

MaxSubCollectionDepth - maximum number of parents a collection can support. Depth is a count of the number of parents for a collection. e.g. a collection with no parent has a depth of 0 a collection with a parent has a depth of 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection struct {
	Name   string
	Parent *Key
}

type Document

type Document struct {
	Key     *Key
	Content map[string]interface{}
}

func (*Document) String

func (d *Document) String() string

type DocumentService

type DocumentService interface {
	Get(*Key) (*Document, error)
	Set(*Key, map[string]interface{}) error
	Delete(*Key) error
	Query(*Collection, []QueryExpression, int, map[string]string) (*QueryResult, error)
}

The base Document Plugin interface Use this over proto definitions to remove dependency on protobuf in the plugin internally and open options to adding additional non-grpc interfaces

type EventService

type EventService interface {
	Publish(topic string, event *NitricEvent) error
	ListTopics() ([]string, error)
}

type FailedTask

type FailedTask struct {
	Task    *NitricTask
	Message string
}

type GatewayService

type GatewayService interface {
	// Start the Gateway
	Start(pool worker.WorkerPool) error
	// Stop the Gateway
	Stop() error
}

type Key

type Key struct {
	Collection *Collection
	Id         string
}

func (*Key) String

func (k *Key) String() string

type NitricContext

type NitricContext struct {
	RequestId   string
	PayloadType string
	Trigger     string
	TriggerType triggers.TriggerType
}

type NitricEvent

type NitricEvent struct {
	ID          string                 `json:"id,omitempty"`
	PayloadType string                 `json:"payloadType,omitempty"`
	Payload     map[string]interface{} `json:"payload,omitempty"`
}

NitricEvent - An event for asynchronous processing and reactive programming

type NitricRequest

type NitricRequest struct {
	Context     *NitricContext
	ContentType string
	Payload     []byte
}

Normalized NitricRequest

type NitricResponse

type NitricResponse struct {
	Headers map[string]string
	Status  int
	Body    []byte
}

type NitricTask

type NitricTask struct {
	ID          string                 `json:"id,omitempty"`
	LeaseID     string                 `json:"leaseId,omitempty"`
	PayloadType string                 `json:"payloadType,omitempty"`
	Payload     map[string]interface{} `json:"payload,omitempty"`
}

NitricTask - A task for asynchronous processing

type QueryExpression

type QueryExpression struct {
	Operand  string
	Operator string
	Value    interface{}
}

type QueryResult

type QueryResult struct {
	Documents   []Document
	PagingToken map[string]string
}

type QueueService

type QueueService interface {
	// Send - Send a single task to a queue
	Send(queue string, task NitricTask) error
	// SendBatch - sends multiple tasks to a queue
	SendBatch(queue string, tasks []NitricTask) (*SendBatchResponse, error)
	// Receive - Receives one or more tasks(s) off a queue
	Receive(options ReceiveOptions) ([]NitricTask, error)
	// Complete - Marks a received task as completed
	Complete(queue string, leaseId string) error
}

QueueService - The Nitric plugin interface for cloud native queue adapters

type ReceiveOptions

type ReceiveOptions struct {
	// Nitric name for the queue.
	//
	// queueName is a required field
	QueueName string `type:"string" required:"true"`

	// Max depth of queue messages to receive from the queue.
	//
	// If nil or 0, defaults to depth 1.
	Depth *uint32 `type:"int" required:"false"`
}

func (*ReceiveOptions) Validate

func (p *ReceiveOptions) Validate() error

type SendBatchResponse

type SendBatchResponse struct {
	FailedTasks []*FailedTask
}

type ServiceFactory

type ServiceFactory interface {
	NewDocumentService() (DocumentService, error)
	NewEventService() (EventService, error)
	NewGatewayService() (GatewayService, error)
	NewQueueService() (QueueService, error)
	NewStorageService() (StorageService, error)
}

ServiceFactory - interface for Service Factory Plugins, which instantiate provider specific service implementations.

type StorageService

type StorageService interface {
	Read(bucket string, key string) ([]byte, error)
	Write(bucket string, key string, object []byte) error
	Delete(bucket string, key string) error
}

type UnimplementedDocumentPlugin

type UnimplementedDocumentPlugin struct {
	DocumentService
}

func (*UnimplementedDocumentPlugin) Delete

func (p *UnimplementedDocumentPlugin) Delete(key *Key) error

func (*UnimplementedDocumentPlugin) Get

func (p *UnimplementedDocumentPlugin) Get(key *Key) (*Document, error)

func (*UnimplementedDocumentPlugin) Query

func (p *UnimplementedDocumentPlugin) Query(collection *Collection, expressions []QueryExpression, limit int, pagingToken map[string]string) (*QueryResult, error)

func (*UnimplementedDocumentPlugin) Set

func (p *UnimplementedDocumentPlugin) Set(key *Key, content map[string]interface{}) error

type UnimplementedEventingPlugin

type UnimplementedEventingPlugin struct {
	EventService
}

func (*UnimplementedEventingPlugin) ListTopics

func (*UnimplementedEventingPlugin) ListTopics() ([]string, error)

func (*UnimplementedEventingPlugin) Publish

func (*UnimplementedEventingPlugin) Publish(topic string, event *NitricEvent) error

type UnimplementedGatewayPlugin

type UnimplementedGatewayPlugin struct {
	GatewayService
}

func (*UnimplementedGatewayPlugin) Start

func (*UnimplementedGatewayPlugin) Stop

type UnimplementedQueuePlugin

type UnimplementedQueuePlugin struct {
	QueueService
}

UnimplementedQueuePlugin - A Default interface, that provide implementations of QueueService methods that Flag the method as unimplemented

func (*UnimplementedQueuePlugin) Complete

func (*UnimplementedQueuePlugin) Complete(queue string, leaseId string) error

func (*UnimplementedQueuePlugin) Receive

func (*UnimplementedQueuePlugin) Send

func (*UnimplementedQueuePlugin) Send(queue string, task NitricTask) error

Push - Unimplemented Stub for the UnimplementedQueuePlugin

func (*UnimplementedQueuePlugin) SendBatch

func (*UnimplementedQueuePlugin) SendBatch(queue string, tasks []NitricTask) (*SendBatchResponse, error)

type UnimplementedServiceFactory

type UnimplementedServiceFactory struct {
}

UnimplementedServiceFactory - provides stub methods for a ServiceFactory which return Unimplemented Methods.

Returning nil from a New service method is a valid response. Without an accompanying error, this will be interpreted as the method being explicitly unimplemented.

Plugin Factories with unimplemented New methods are only supported when the TOLERATE_MISSING_SERVICE option is set to true when executing the pluggable membrane.

func (*UnimplementedServiceFactory) NewDocumentService

func (p *UnimplementedServiceFactory) NewDocumentService() (DocumentService, error)

NewDocumentService - Unimplemented

func (*UnimplementedServiceFactory) NewEventService

func (p *UnimplementedServiceFactory) NewEventService() (EventService, error)

NewEventService - Unimplemented

func (*UnimplementedServiceFactory) NewGatewayService

func (p *UnimplementedServiceFactory) NewGatewayService() (GatewayService, error)

NewGatewayService - Unimplemented

func (*UnimplementedServiceFactory) NewQueueService

func (p *UnimplementedServiceFactory) NewQueueService() (QueueService, error)

NewQueueService - Unimplemented

func (*UnimplementedServiceFactory) NewStorageService

func (p *UnimplementedServiceFactory) NewStorageService() (StorageService, error)

NewStorageService - Unimplemented

type UnimplementedStoragePlugin

type UnimplementedStoragePlugin struct{}

func (*UnimplementedStoragePlugin) Delete

func (*UnimplementedStoragePlugin) Delete(bucket string, key string) error

func (*UnimplementedStoragePlugin) Read

func (*UnimplementedStoragePlugin) Read(bucket string, key string) ([]byte, error)

func (*UnimplementedStoragePlugin) Write

func (*UnimplementedStoragePlugin) Write(bucket string, key string, object []byte) error

Jump to

Keyboard shortcuts

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