pubsub

package
v1.2.16 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxTopicNameLen .
	MaxTopicNameLen = 1024
)

Variables

View Source
var (
	// ErrInvalidPassword .
	ErrInvalidPassword = errors.New("invalid password")

	// ErrInvalidTopicEmpty .
	ErrInvalidTopicEmpty = errors.New("invalid topic, should not be \"\"")

	// ErrInvalidTopicBytes .
	ErrInvalidTopicBytes = errors.New("invalid topic bytes, should be more than 10 bytes")

	// ErrInvalidTopicNameLength .
	ErrInvalidTopicNameLength = errors.New("invalid topic name length, should not be more than 1024")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	*arpc.Client

	Password string
	// contains filtered or unexported fields
}

Client .

func NewClient

func NewClient(dialer func() (net.Conn, error), args ...interface{}) (*Client, error)

NewClient .

func (*Client) Authenticate

func (c *Client) Authenticate() error

Authenticate .

func (*Client) OnPublish

func (c *Client) OnPublish(h TopicHandler)

OnPublish .

func (*Client) Publish

func (c *Client) Publish(topicName string, v interface{}, timeout time.Duration) error

Publish .

func (*Client) PublishToOne

func (c *Client) PublishToOne(topicName string, v interface{}, timeout time.Duration) error

PublishToOne .

func (*Client) Subscribe

func (c *Client) Subscribe(topicName string, h TopicHandler, timeout time.Duration) error

Subscribe .

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(topicName string, timeout time.Duration) error

Unsubscribe .

type Server

type Server struct {
	*arpc.Server

	Password string
	// contains filtered or unexported fields
}

Server .

func NewServer

func NewServer() *Server

NewServer .

func (*Server) Publish

func (s *Server) Publish(topicName string, v interface{}) error

Publish topic

func (*Server) PublishToOne

func (s *Server) PublishToOne(topicName string, v interface{}) error

PublishToOne topic

type Topic

type Topic struct {
	Name      string
	Data      []byte
	Timestamp int64
	// contains filtered or unexported fields
}

Topic .

type TopicAgent

type TopicAgent struct {
	Name string
	// contains filtered or unexported fields
}

TopicAgent .

func (*TopicAgent) Add

func (t *TopicAgent) Add(c *arpc.Client)

Add .

func (*TopicAgent) Delete

func (t *TopicAgent) Delete(c *arpc.Client)

Delete .

func (*TopicAgent) Publish

func (t *TopicAgent) Publish(s *Server, from *arpc.Client, topic *Topic)

Publish .

func (*TopicAgent) PublishToOne

func (t *TopicAgent) PublishToOne(s *Server, from *arpc.Client, topic *Topic)

PublishToOne .

type TopicHandler

type TopicHandler func(tp *Topic)

TopicHandler .

Jump to

Keyboard shortcuts

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