pubsub

package
v0.0.0-...-690eaa8 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Copyright 2018 The Elasticshift Authors.

Copyright 2018 The Elasticshift Authors.

Copyright 2018 The Elasticshift Authors.

Copyright 2018 The Elasticshift Authors.

Package pubsub ..

Copyright 2018 The Elasticshift Authors.

Copyright 2018 The Elasticshift Authors.

Copyright 2018 The Elasticshift Authors.

Copyright 2018 The Elasticshift Authors.

Package pubsub ...

Copyright 2018 The Elasticshift Authors.

Index

Constants

View Source
const (
	// CONCURRENCY ..
	// max concurreny the listener should be
	CONCURRENCY = 200
)

Variables

View Source
var (
	SubscribeBuildUpdate = "subscribe_build_update"
)

subscription query names

Functions

func NewGraphqlWSHandler

func NewGraphqlWSHandler(engine Engine, loggr logger.Loggr) http.Handler

NewHandler ..

Types

type Connection

type Connection interface {
	ID() string

	PushData(id string, response *SubscriptionResponse)

	PushError(err error)
	PushSubscriptionError(id string, err []error)
}

Connection ..

type ConnectionSubscriptions

type ConnectionSubscriptions map[string]*Subscription

ConnectionSubscriptions ..

type Consumer

type Consumer interface {
	Subscribe(topic string) error
	Unsubscribe()
}

Consumer ..

func NewConsumer

func NewConsumer(cfg NSQConfig, logger *logrus.Entry, schema *graphql.Schema, consumers *consumers) Consumer

NewConsumer ..

type ConsumerConfig

type ConsumerConfig struct {
	NSQConfig   NSQConfig
	HandlerFunc CosumerHandleFunc
	Topic       string
	Channel     string
}

ConsumerConfig ..

type Consumers

type Consumers interface {
	Schema(schema *graphql.Schema)

	Add(topic string, s *Subscription) error
	Remove(topic string, s *Subscription)
}

func NewConsumers

func NewConsumers(cfg NSQConfig, loggr logger.Loggr) Consumers

type CosumerHandleFunc

type CosumerHandleFunc func(m Message) error

CosumerHandleFunc ..

type Engine

type Engine interface {
	Producer() (Producer, error)
	Consumers() Consumers
	SubscriptionHandler() SubscriptionHandler

	Publish(topic string, payload interface{}) error

	Schema(schema *graphql.Schema)
}

Engine ..

func NewEngine

func NewEngine(loggr logger.Loggr, sh SubscriptionHandler, conf NSQConfig, cons Consumers) Engine

NewEngine ..

type EventHandler

type EventHandler struct {
	Subscribe   func(Connection, string, *SubscriptionRequest) []error
	Unsubscribe func(Connection, string)
	Close       func(Connection)
}

EventHandler ..

type Message

type Message struct {
	//nsq.Message
	Topic   string      `json:"topic,omitempty"` // topic to publish or consume, as well as subscription name
	Payload interface{} `json:"payload,omitempty"`
}

Message ..

func NewMessage

func NewMessage(msg *nsq.Message) (*Message, error)

NewMessage ..

type NSQConfig

type NSQConfig struct {
	Consumer struct {
		Address string
		Config  *nsq.Config
	}
	Producer struct {
		Address string
		Config  *nsq.Config
	}
}

NSQConfig ..

type Producer

type Producer interface {
	Publish(topic string, payload interface{}) error
}

Producer ..

func NewProducer

func NewProducer(cfg NSQConfig, sh SubscriptionHandler, loggr logger.Loggr) (Producer, error)

NewProducer ..

type PushResponseFunc

type PushResponseFunc func(*SubscriptionResponse)

PushResponseFunc ..

type Subscription

type Subscription struct {
	ID            string
	Query         string
	Variables     map[string]interface{}
	OperationName string
	Conenction    Connection
	Push          PushResponseFunc
	Topic         string
	OperationID   string
}

Subscription ..

type SubscriptionHandler

type SubscriptionHandler interface {
	Subcribe(Connection, *Subscription) []error
	UnsubscribeAll(Connection)
	Unsubscribe(Connection, *Subscription)
	Subscriptions() Subscriptions

	Schema(schema *graphql.Schema)
}

SubscriptionHandler ..

func NewSubscriptionHandler

func NewSubscriptionHandler(loggr logger.Loggr, cons Consumers) SubscriptionHandler

NewSubscriptionHandler ..

type SubscriptionRequest

type SubscriptionRequest struct {
	OperationName string                 `json:"operation_name,omitempty"`
	Query         string                 `json:"query,omitempty"`
	Variables     map[string]interface{} `json:"variables,omitempty"`
}

SubscriptionRequest ..

type SubscriptionResponse

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

SubscriptionResponse ..

type Subscriptions

type Subscriptions map[Connection]ConnectionSubscriptions

Subscriptions ..

type WebsocketMessage

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

WebsocketMessage ..

func (WebsocketMessage) String

func (msg WebsocketMessage) String() string

Jump to

Keyboard shortcuts

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