api

package
v0.0.0-...-077b43f Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ShadowRetry = "retry"
	ShadowDead  = "dead"

	UserAgent = "pubsub-go v0.1"
)

Variables

View Source
var (
	ErrSubStop     = errors.New("sub stopped")
	ErrInvalidBury = errors.New("invalid bury name")
)

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(cf *Config) *Client

NewClient will create a PubSub client.

func (*Client) AddJob

func (this *Client) AddJob(payload []byte, delay string, opt PubOption) (jobId string, err error)

func (*Client) AddTopic

func (this *Client) AddTopic(cluster, appid, topic, ver string) (err error)

func (*Client) Close

func (this *Client) Close()

func (*Client) DeleteJob

func (this *Client) DeleteJob(jobId string, opt PubOption) (err error)

func (*Client) Pub

func (this *Client) Pub(key string, msg []byte, opt PubOption) (err error)

Pub publish a keyed message to specified versioned topic.

func (*Client) Sub

func (this *Client) Sub(opt SubOption, h SubHandler) error

func (*Client) SubX

func (this *Client) SubX(opt SubOption, h SubXHandler) error

SubX is advanced Sub with features of delayed ack and shadow bury.

type Config

type Config struct {
	AppId  string
	Secret string

	Timeout   time.Duration
	KeepAlive time.Duration

	Sub struct {
		Scheme   string // https or http
		Endpoint string // host:port
	}

	Pub struct {
		Scheme   string // http or https
		Endpoint string // host:port
	}

	Admin struct {
		Scheme   string
		Endpoint string
	}

	Debug bool
}

func DefaultConfig

func DefaultConfig(appid, secret string) *Config

type PubOption

type PubOption struct {
	Topic, Ver string
	Async      bool
	AckAll     bool
	Tag        string
}

type SubHandler

type SubHandler func(statusCode int, msg []byte) error

type SubOption

type SubOption struct {
	AppId      string
	Topic, Ver string
	Group      string
	Batch      int
	Reset      string // newest | oldest
	Shadow     string
	Wait       string
	Tag        string // tag filter
	AutoClose  bool
	Mux        bool
}

type SubXHandler

type SubXHandler func(statusCode int, msg []byte, r *SubXResult) error

type SubXResult

type SubXResult struct {
	Bury      string
	Offset    string
	Partition string
	Tag       string
}

func (*SubXResult) Reset

func (this *SubXResult) Reset()

Jump to

Keyboard shortcuts

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