manager

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteKeyConnect    string = "$connect"
	RouteKeyDisconnect string = "$disconnect"
	RouteKeyDefault    string = "$default"
)
View Source
const (
	// client
	GraphQLSubStart            string = "start"
	GraphQLSubStop             string = "stop"
	GraphQLConnectionInit      string = "connection_init"
	GraphQLConnectionTerminate string = "connection_terminate"
	// server
	GraphQLConnectionACK string = "connection_ack"
	GraphQLError         string = "error"
	GraphQLData          string = "data"
	GraphQLComplete      string = "complete"
)

Variables

This section is empty.

Functions

func DynamoDBStream

func DynamoDBStream(ctx context.Context, req events.DynamoDBEvent) error

func Execute

func Execute(
	operationID string,
	connectionID string,
	domainName string,
	stage string,
	params *graphql.Params,
)

func Pub

func Pub(key string, payload map[string]interface{}) error

func SetManager

func SetManager(args *SetManagerArgs)

func Sub

func Sub(keys []string, ctx context.Context) (interface{}, error)

Types

type Connection

type Connection struct {
	Id                      string      `dynamodbav:"id"`
	Domain                  string      `dynamodbav:"domain"`
	Stage                   string      `dynamodbav:"stage"`
	Context                 string      `dynamodbav:"context"`
	IsInitialized           bool        `dynamodbav:"isInitialized"`
	CreatedAt               *time.Time  `dynamodbav:"createdAt"`
	WebsocketConnectContext interface{} `dynamodbav:"websocketConnectContext"`
	ConnectContext          interface{} `dynamodbav:"connectContext"`
	Ttl                     int64       `dynamodbav:"ttl"`
}

type ConnectionManager

type ConnectionManager interface {
	OnConnect(newConnection *Connection) error
	OnDisconnect(connectionID string) error
	Get(connectionID string) (*Connection, error)
	Init(connectionID string, connectContext interface{}) error
	Terminate(connectionID string) error
	Hydrate(connectionId string) error
}

type ContextKey

type ContextKey int
const WSContextKey ContextKey = iota

type Event

type Event struct {
	ID      string      `dynamodbav:"id"`
	Key     string      `dynamodbav:"key"`
	Payload interface{} `dynamodbav:"payload"`
}

type EventManager

type EventManager interface {
	Add(newEvent *Event) error
	Remove(eventId string) error
}

type Local

type Local struct {
	Enable    bool
	OnPublish *func(key string, payload map[string]interface{})
}

type Manager

type Manager struct {
	Schema             *graphql.Schema
	Connection         ConnectionManager
	Subscription       SubscriptionManager
	Event              EventManager
	OnWebsocketConnect *func(*events.APIGatewayWebsocketProxyRequest) interface{}
	OnConnect          *func(*events.APIGatewayWebsocketProxyRequest) interface{}
	OnDisconnect       *func(*Connection)
}
var CurrentManager *Manager

type Message

type Message struct {
	OperationID string `json:"id,omitempty"`
	Type        string `json:"type"`
	Payload     struct {
		Query         string                 `json:"query,omitempty"`
		Variables     map[string]interface{} `json:"variables,omitempty"`
		OperationName string                 `json:"operationName,omitempty"`
	} `json:"payload,omitempty"`
}

type SetManagerArgs

type SetManagerArgs struct {
	Schema             *graphql.Schema
	Connection         ConnectionManager
	Subscription       SubscriptionManager
	Event              EventManager
	OnWebsocketConnect *func(*events.APIGatewayWebsocketProxyRequest) interface{}
	OnConnect          *func(*events.APIGatewayWebsocketProxyRequest) interface{}
	OnDisconnect       *func(*Connection)
}

type Subscription

type Subscription struct {
	Event         string                 `dynamodbav:"event"`
	ConnectionID  string                 `dynamodbav:"connectionId"`
	OperationID   string                 `dynamodbav:"operationId"`
	Query         string                 `dynamodbav:"query"`
	Variables     map[string]interface{} `dynamodbav:"variables"`
	OperationName string                 `dynamodbav:"operationName"`
	Ttl           int64                  `dynamodbav:"ttl"`
}

type SubscriptionManager

type SubscriptionManager interface {
	Start(subscription *Subscription) error
	Stop(connectionID string, operationID string) error
	ListByEvents(eventKey string, from *string) (*SubscriptionResponse, error)
}

type SubscriptionResponse

type SubscriptionResponse struct {
	Items *[]Subscription
	Next  *string
}

type WSlambdaContext

type WSlambdaContext struct {
	OperationID             string
	ConnectionID            string
	DomainName              string
	Stage                   string
	RequestString           string
	Variables               map[string]interface{}
	OperationName           string
	WebsocketConnectContext interface{}
	ConnectContext          interface{}
}

Jump to

Keyboard shortcuts

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