nitric

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewQueue

func NewQueue(name string) *queue

func NewSecret

func NewSecret(name string) *secret

func Run

func Run() error

Run will run the function and callback the required handlers when these events are received.

Types

type Api

type Api interface {
	Get(path string, handler faas.HttpMiddleware, opts ...MethodOption)
	Put(path string, handler faas.HttpMiddleware, opts ...MethodOption)
	Patch(path string, handler faas.HttpMiddleware, opts ...MethodOption)
	Post(path string, handler faas.HttpMiddleware, opts ...MethodOption)
	Delete(path string, handler faas.HttpMiddleware, opts ...MethodOption)
	Options(path string, handler faas.HttpMiddleware, opts ...MethodOption)
	NewRoute(path string, middleware ...faas.HttpMiddleware) Route
	Details(ctx context.Context) (*ApiDetails, error)
}

Api Resource represents an HTTP API, capable of routing and securing incoming HTTP requests to handlers. path is the route path matcher e.g. '/home'. Supports path params via colon prefix e.g. '/customers/:customerId' handler the handler to register for callbacks.

Note: to chain middleware use faas.ComposeHttpMiddlware()

func NewApi

func NewApi(name string, opts ...ApiOption) (Api, error)

NewApi Registers a new API Resource.

The returned API object can be used to register Routes and Methods, with Handlers.

type ApiDetails

type ApiDetails struct {
	Details
	URL string
}

type ApiOption

type ApiOption = func(api *api)

func WithMiddleware

func WithMiddleware(middleware ...faas.HttpMiddleware) ApiOption

func WithPath

func WithPath(path string) ApiOption

WithPath - Prefixes API with the given path

func WithSecurity

func WithSecurity(name string, scopes []string) ApiOption

func WithSecurityJwtRule

func WithSecurityJwtRule(name string, rule JwtSecurityRule) ApiOption

type Bucket

type Bucket interface {
	With(permissions ...BucketPermission) (storage.Bucket, error)
	On(faas.NotificationType, string, ...faas.BucketNotificationMiddleware)
}

func NewBucket

func NewBucket(name string) Bucket

NewBucket register this bucket as a required resource for the calling function/container and register the permissions required by the currently scoped function for this resource.

type BucketPermission

type BucketPermission string
const (
	BucketReading  BucketPermission = "reading"
	BucketWriting  BucketPermission = "writing"
	BucketDeleting BucketPermission = "deleting"
)

type Collection

type Collection interface {
	With(permissions ...CollectionPermission) (documents.CollectionRef, error)
}

func NewCollection

func NewCollection(name string) Collection

NewCollection register this collection as a required resource for the calling function/container.

type CollectionPermission

type CollectionPermission string
const (
	CollectionReading  CollectionPermission = "reading"
	CollectionWriting  CollectionPermission = "writing"
	CollectionDeleting CollectionPermission = "deleting"
)

type Details

type Details struct {
	// The identifier of the resource
	ID string
	// The provider this resource is deployed with (e.g. aws)
	Provider string
	// The service this resource is deployed on (e.g. ApiGateway)
	Service string
}

type JwtSecurityRule

type JwtSecurityRule struct {
	Issuer    string
	Audiences []string
}

type Manager

type Manager interface {
	Run() error
	// contains filtered or unexported methods
}

Manager is the top level object that resources are created on.

func New

func New() Manager

New is used to create the top level resource manager. Note: this is not required if you are using resources.NewApi() and the like. These use a default manager instance.

type MethodOption

type MethodOption = func(mo *methodOptions)

func WithMethodSecurity

func WithMethodSecurity(name string, scopes []string) MethodOption

func WithNoMethodSecurity

func WithNoMethodSecurity() MethodOption

type Queue

type Queue interface {
	With(...QueuePermission) (queues.Queue, error)
}

type QueuePermission

type QueuePermission string
const (
	QueueSending   QueuePermission = "sending"
	QueueReceiving QueuePermission = "receiving"
)

type Route

type Route interface {
	All(handler faas.HttpMiddleware, opts ...MethodOption)
	Get(handler faas.HttpMiddleware, opts ...MethodOption)
	Patch(handler faas.HttpMiddleware, opts ...MethodOption)
	Put(handler faas.HttpMiddleware, opts ...MethodOption)
	Post(handler faas.HttpMiddleware, opts ...MethodOption)
	Delete(handler faas.HttpMiddleware, opts ...MethodOption)
	Options(handler faas.HttpMiddleware, opts ...MethodOption)
}

Route providers convenience functions to register a handler in a single method.

type Schedule

type Schedule interface {
	Cron(cron string, middleware ...faas.EventMiddleware)
	Every(rate string, middleware ...faas.EventMiddleware) error
}

func NewSchedule

func NewSchedule(name string) Schedule

NewSchedule provides a new schedule, which can be configured with a rate/cron and a callback to run on the schedule.

type Secret

type Secret interface{}

type SecretPermission

type SecretPermission string
const (
	SecretAccessing SecretPermission = "accessing"
	SecretPutting   SecretPermission = "putting"
)

type Starter

type Starter interface {
	Start() error
}

type SubscribableTopic

type SubscribableTopic interface {
	With(permissions ...TopicPermission) (Topic, error)

	// Subscribe will register and start a subscription handler that will be called for all events from this topic.
	Subscribe(...faas.EventMiddleware)
}

func NewTopic

func NewTopic(name string) SubscribableTopic

NewTopic creates a new Topic with the give permissions.

type Topic

type Topic interface {
	events.Topic
}

type TopicPermission

type TopicPermission string

TopicPermission defines the available permissions on a topic

const (
	// TopicPublishing is required to call Publish on a topic.
	TopicPublishing TopicPermission = "publishing"
)

type Websocket

type Websocket interface {
	Name() string
	On(eventType faas.WebsocketEventType, mwares ...faas.WebsocketMiddleware)
	Send(ctx context.Context, connectionId string, message []byte) error
	Close(ctx context.Context, connectionId string) error
}

func NewWebsocket

func NewWebsocket(name string) (Websocket, error)

NewCollection register this collection as a required resource for the calling function/container.

Jump to

Keyboard shortcuts

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