push

package
v3.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	*core.Service

	Timeout       time.Duration
	HeartBeat     time.Duration
	OnSubscribe   func(ctx context.Context, id string, topic string)
	OnUnsubscribe func(ctx context.Context, id string, topic string, messages []Message)
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker(service *core.Service) *Broker

func (*Broker) Broadcast

func (b *Broker) Broadcast(ctx context.Context, data interface{}, topic string, from string) map[string]bool

func (*Broker) Deny

func (b *Broker) Deny(ctx context.Context, id string, topic string)

func (*Broker) Exists

func (b *Broker) Exists(topic string, id string) bool

func (*Broker) ID

func (b *Broker) ID(ctx context.Context) (id string)

func (*Broker) IdList

func (b *Broker) IdList(topic string) (idlist []string)

func (*Broker) Multicast

func (b *Broker) Multicast(ctx context.Context, data interface{}, topic string, ids []string, from string) map[string]bool

func (*Broker) Push

func (b *Broker) Push(data interface{}, topic string, id ...string) map[string]bool

func (*Broker) Unicast

func (b *Broker) Unicast(ctx context.Context, data interface{}, topic string, id string, from string) bool

type Callback

type Callback interface{}

type Message

type Message struct {
	Data interface{} `json:"data"`
	From string      `json:"from"`
}

type MessageCache

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

func (*MessageCache) Append

func (m *MessageCache) Append(message Message)

func (*MessageCache) Take

func (m *MessageCache) Take() (result []Message)

type Producer

type Producer interface {
	From() string
	Unicast(ctx context.Context, data interface{}, topic string, id string) bool
	Multicast(ctx context.Context, data interface{}, topic string, ids []string) map[string]bool
	Broadcast(ctx context.Context, data interface{}, topic string) map[string]bool
	Push(data interface{}, topic string, id ...string) map[string]bool
	Deny(ctx context.Context, id string, topic string)
	Exists(topic string, id string) bool
	IdList(topic string) []string
}

func GetProducer

func GetProducer(ctx context.Context) Producer

type Prosumer

type Prosumer struct {
	RetryInterval time.Duration
	OnError       func(error)
	OnSubscribe   func(topic string)
	OnUnsubscribe func(topic string)
	// contains filtered or unexported fields
}

func NewProsumer

func NewProsumer(client *core.Client, id ...string) *Prosumer

func (*Prosumer) Broadcast

func (p *Prosumer) Broadcast(data interface{}, topic string) (map[string]bool, error)

func (*Prosumer) Client

func (p *Prosumer) Client() *core.Client

func (*Prosumer) Exists

func (p *Prosumer) Exists(topic string, id string) (bool, error)

func (*Prosumer) ID

func (p *Prosumer) ID() (id string)

func (*Prosumer) IdList

func (p *Prosumer) IdList(topic string) ([]string, error)

func (*Prosumer) Multicast

func (p *Prosumer) Multicast(data interface{}, topic string, ids []string) (map[string]bool, error)

func (*Prosumer) Push

func (p *Prosumer) Push(data interface{}, topic string, id ...string) (map[string]bool, error)

func (*Prosumer) SetID

func (p *Prosumer) SetID(id string)

func (*Prosumer) Subscribe

func (p *Prosumer) Subscribe(topic string, callback Callback) (result bool, err error)

func (*Prosumer) Unicast

func (p *Prosumer) Unicast(data interface{}, topic string, id string) (bool, error)

func (*Prosumer) Unsubscribe

func (p *Prosumer) Unsubscribe(topic string) (result bool, err error)

Jump to

Keyboard shortcuts

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