pushlib

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartChildProcess

func StartChildProcess(url string)

Types

type Library

type Library struct {
	// contains filtered or unexported fields
}

func New

func New(subscriptionId string, adapter PushAdapter) *Library

func (*Library) AttachPushHandler

func (l *Library) AttachPushHandler(path string, authToken string)

attach to receive Pusher's pushes at a defined path, example: "/_eventhorizon_push"

func (*Library) Push

func (l *Library) Push(input *ptypes.PushInput) (*ptypes.PushOutput, error)

called by the HTTP endpoint for pushing. returns PushOutput for sending status back to Pusher

type PushAdapter

type PushAdapter interface {
	// PushWrapTransaction() is an API that pushlib calls to wrap all
	// following operations in a single transaction. we:
	//
	//     1) start transaction
	//     2) call back to pushlib with "run" with the transaction, after which pusher calls:
	//        - PushGetOffset()
	//        - PushHandleEvent() multiple times
	//        - PushSetOffset()
	//     3) app gets back error state from "run" callback indicating if anything went
	//        wrong. if we get error back we must rollback the transaction, otherwise commit.
	PushWrapTransaction(run func(tx interface{}) error) error
	PushGetOffset(stream string, tx interface{}) (string, error)
	PushSetOffset(stream string, offset string, tx interface{}) error
	PushHandleEvent(line *rtypes.ReadResultLine, tx interface{}) error
}

Sequence of events, success: ----------------------------

PushWrapTransaction

PushGetOffset
PushHandleEvent
PushHandleEvent
PushHandleEvent
PushSetOffset

Sequence of events, failure: ----------------------------

PushWrapTransaction

PushGetOffset
PushHandleEvent => error => stop

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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