pubsub

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package pubsub *

  • @Author: W.w.
  • @File: pubsub
  • @Date: 2023-06-01 17:01
  • @Description:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Publisher

type Publisher struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Publisher *****************************************************

  • @Description: 发布者对象 *****************************************************

func NewPublisher

func NewPublisher(publishTimeout time.Duration, buffer int) *Publisher

NewPublisher *****************************************************

  • @Description: 构建一个发布者对象, 可以设置发布超时时间和缓存队列的长度
  • @param publishTimeout
  • @param buffer
  • @return *Publisher *****************************************************

func (*Publisher) Close

func (p *Publisher) Close()

Close *****************************************************

  • @Description: 关闭发布者对象,同时关闭所有的订阅者管道。
  • @receiver p *****************************************************

func (*Publisher) Publish

func (p *Publisher) Publish(v any)

Publish *****************************************************

  • @Description: 发布一个消息
  • @receiver p
  • @param v *****************************************************

func (*Publisher) Subscribe

func (p *Publisher) Subscribe() chan any

Subscribe *****************************************************

  • @Description: 添加一个新的订阅者,订阅全部主题
  • @receiver p
  • @return chan any *****************************************************

func (*Publisher) SubscribeTopic

func (p *Publisher) SubscribeTopic(topic topicFunc) chan any

SubscribeTopic *****************************************************

  • @Description: 添加一个新的订阅者,订阅过滤器筛选后的主题
  • @receiver p
  • @param topic
  • @return chan any *****************************************************

func (*Publisher) Unsubscribe

func (p *Publisher) Unsubscribe(sub chan any)

Unsubscribe *****************************************************

  • @Description: 取消订阅
  • @receiver p
  • @param sub *****************************************************

Jump to

Keyboard shortcuts

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