gws

package
v0.0.0-...-77132cc Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package gws is a generated protocol buffer package.

It is generated from these files:

distribution.proto

It has these top-level messages:

Distribution
Filter
Condition

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorsFromGraphQLErrors

func ErrorsFromGraphQLErrors(errors []gqlerrors.FormattedError) []error

ErrorsFromGraphQLErrors convert from GraphQL errors to regular errors.

Types

type AuthorizeFunc

type AuthorizeFunc func(Context, string) error

AuthorizeFunc type

type CacheAdaptor

type CacheAdaptor interface {
	Set(key []byte, data []byte, ttl time.Duration) error
	Get(key []byte) ([]byte, error)
}

CacheAdaptor interface

type Condition

type Condition struct {
	EqIDs  []int64  `protobuf:"varint,10,rep,packed,name=EqIDs" json:"EqIDs,omitempty"`
	NeIDs  []int64  `protobuf:"varint,11,rep,packed,name=NeIDs" json:"NeIDs,omitempty"`
	EqKeys []string `protobuf:"bytes,20,rep,name=EqKeys" json:"EqKeys,omitempty"`
	NeKeys []string `protobuf:"bytes,21,rep,name=NeKeys" json:"NeKeys,omitempty"`
}

func (*Condition) Descriptor

func (*Condition) Descriptor() ([]byte, []int)

func (*Condition) GetEqIDs

func (m *Condition) GetEqIDs() []int64

func (*Condition) GetEqKeys

func (m *Condition) GetEqKeys() []string

func (*Condition) GetNeIDs

func (m *Condition) GetNeIDs() []int64

func (*Condition) GetNeKeys

func (m *Condition) GetNeKeys() []string

func (*Condition) ProtoMessage

func (*Condition) ProtoMessage()

func (*Condition) Reset

func (m *Condition) Reset()

func (*Condition) String

func (m *Condition) String() string

type Context

type Context interface {
	Identity() Identity
	MachineID() string
	ProcessID() string
	Context() context.Context
	Req() *http.Request
	Res() http.ResponseWriter
	Client() router.Client
	Cookie() router.Cookie
	Header() router.Header
	Subscriptions() Subscriptions
	Connection() *websocket.Conn
	Cache() CacheAdaptor
	Message() MessageAdaptor
	Write(string, interface{}) error
	Error(string, interface{}) error
	Close() error
	BeforeOpen()
	AfterClose()
}

Context interface

type DataMessagePayload

type DataMessagePayload struct {
	Data   interface{} `json:"data"`
	Errors []error     `json:"errors"`
}

DataMessagePayload defines the result data of an operation.

type Distribution

type Distribution struct {
	Field     string     `protobuf:"bytes,10,opt,name=field" json:"field,omitempty"`
	Payload   []byte     `protobuf:"bytes,20,opt,name=payload,proto3" json:"payload,omitempty"`
	Filters   []*Filter  `protobuf:"bytes,30,rep,name=filters" json:"filters,omitempty"`
	Condition *Condition `protobuf:"bytes,50,opt,name=condition" json:"condition,omitempty"`
	Strict    bool       `protobuf:"varint,60,opt,name=strict" json:"strict,omitempty"`
}

func (*Distribution) Descriptor

func (*Distribution) Descriptor() ([]byte, []int)

func (*Distribution) GetCondition

func (m *Distribution) GetCondition() *Condition

func (*Distribution) GetField

func (m *Distribution) GetField() string

func (*Distribution) GetFilters

func (m *Distribution) GetFilters() []*Filter

func (*Distribution) GetPayload

func (m *Distribution) GetPayload() []byte

func (*Distribution) GetStrict

func (m *Distribution) GetStrict() bool

func (*Distribution) ProtoMessage

func (*Distribution) ProtoMessage()

func (*Distribution) Reset

func (m *Distribution) Reset()

func (*Distribution) String

func (m *Distribution) String() string

type Filter

type Filter struct {
	Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
	// Types that are valid to be assigned to ValOneof:
	//	*Filter_StringValue
	//	*Filter_IntValue
	//	*Filter_FloatValue
	//	*Filter_BoolValue
	//	*Filter_BytesValue
	//	*Filter_TimeValue
	ValOneof isFilter_ValOneof `protobuf_oneof:"val_oneof"`
}

func (*Filter) Descriptor

func (*Filter) Descriptor() ([]byte, []int)

func (*Filter) GetBoolValue

func (m *Filter) GetBoolValue() bool

func (*Filter) GetBytesValue

func (m *Filter) GetBytesValue() []byte

func (*Filter) GetFloatValue

func (m *Filter) GetFloatValue() float64

func (*Filter) GetIntValue

func (m *Filter) GetIntValue() int64

func (*Filter) GetKey

func (m *Filter) GetKey() string

func (*Filter) GetStringValue

func (m *Filter) GetStringValue() string

func (*Filter) GetTimeValue

func (m *Filter) GetTimeValue() int64

func (*Filter) GetValOneof

func (m *Filter) GetValOneof() isFilter_ValOneof

func (*Filter) ProtoMessage

func (*Filter) ProtoMessage()

func (*Filter) Reset

func (m *Filter) Reset()

func (*Filter) String

func (m *Filter) String() string

func (*Filter) XXX_OneofFuncs

func (*Filter) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type Filter_BoolValue

type Filter_BoolValue struct {
	BoolValue bool `protobuf:"varint,13,opt,name=bool_value,json=boolValue,oneof"`
}

type Filter_BytesValue

type Filter_BytesValue struct {
	BytesValue []byte `protobuf:"bytes,14,opt,name=bytes_value,json=bytesValue,proto3,oneof"`
}

type Filter_FloatValue

type Filter_FloatValue struct {
	FloatValue float64 `protobuf:"fixed64,12,opt,name=float_value,json=floatValue,oneof"`
}

type Filter_IntValue

type Filter_IntValue struct {
	IntValue int64 `protobuf:"varint,11,opt,name=int_value,json=intValue,oneof"`
}

type Filter_StringValue

type Filter_StringValue struct {
	StringValue string `protobuf:"bytes,10,opt,name=string_value,json=stringValue,oneof"`
}

type Filter_TimeValue

type Filter_TimeValue struct {
	TimeValue int64 `protobuf:"varint,15,opt,name=time_value,json=timeValue,oneof"`
}

type HandlerFunc

type HandlerFunc func([]byte, Context)

HandlerFunc type

type HookFunc

type HookFunc func(Context)

HookFunc type

type Identity

type Identity interface {
	HasID() bool
	GetID() int
	SetID(int)
	HasKey() bool
	GetKey() string
	SetKey(string)
}

Identity interface

type InitMessagePayload

type InitMessagePayload struct {
	AuthToken string `json:"authToken"`
}

InitMessagePayload defines the parameters of a connection init message.

type MessageAdaptor

type MessageAdaptor interface {
	Emit([]byte, []byte) error
	Listen([]byte, message.Handler) message.Close
}

MessageAdaptor broker interface

type OperationMessage

type OperationMessage struct {
	ID      string      `json:"id,omitempty"`
	Type    string      `json:"type"`
	Payload interface{} `json:"payload,omitempty"`
}

OperationMessage represents a GraphQL WebSocket message.

func (*OperationMessage) Marshal

func (msg *OperationMessage) Marshal() []byte

Marshal helper func

func (*OperationMessage) String

func (msg *OperationMessage) String() string

func (*OperationMessage) Unmarshal

func (msg *OperationMessage) Unmarshal(b []byte) error

Unmarshal helper func

type Option

type Option func(*Options)

Option func

func Cache

func Cache(v cache.Service) Option

Cache to set custom cache engine

func ID

func ID(s string) Option

ID to change server reference id

func Message

func Message(m message.Service) Option

Message to set custom message broker

func Schema

func Schema(v graphql.Schema) Option

Schema to set graphql schema

func Topic

func Topic(s string) Option

Topic to set message broker pub-sub topic

type Options

type Options struct {

	// engine server unique id
	ID string

	// message broker topic
	Topic []byte

	// graphql schema
	Schema graphql.Schema

	// cache engine
	Cache cache.Service

	// message broker
	Message message.Service
}

Options is the engine server options

type Service

type Service interface {
	Start() error
	Stop() error
	Publish(*Distribution) error
	Subscribe(*Distribution) error
	Subscriptions() Store
	Handle(router.Context, *websocket.Conn)
	Schema(graphql.Schema)
	Adaptor() router.GQLSubscriptionAdaptor
	Authorize(AuthorizeFunc)
	BeforeOpen(HookFunc)
	AfterClose(HookFunc)
	String() string
}

Service interface

func New

func New(opts ...Option) Service

New creates engine server

type StartMessagePayload

type StartMessagePayload struct {
	Query         string                 `json:"query"`
	Variables     map[string]interface{} `json:"variables"`
	OperationName string                 `json:"operationName"`
}

StartMessagePayload defines the parameters of an operation that a client requests to be started.

type Store

type Store interface {
	Has(Subscription) bool
	Add(Subscription, ...bool) bool
	Del(Subscription) bool
	Get(...string) []Subscription
}

Store interface

type Subscription

type Subscription interface {
	ID() string
	Query() string
	Variables() map[string]interface{}
	Arguments() map[string]interface{}
	OperationName() string
	Document() *ast.Document
	Fields() []string
	Connection() Context
}

Subscription interface

type Subscriptions

type Subscriptions interface {
	Has(string) bool
	Add(Subscription, ...bool) bool
	Del(Subscription) bool
	Get(string) Subscription
	List() []Subscription
	Len() int
}

Subscriptions interface

Jump to

Keyboard shortcuts

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