tcp

package
v0.0.0-...-83adff0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth(d *dsn.DSN, addr string) (cfg *conf.Kafka, batch int64, err error)

Auth 校验认证信息并反回相应配置 与 http 接口共用,不要在此方法执行 io 操作

func Close

func Close()

Close close all producers and consumers

func ConsumerAddrs

func ConsumerAddrs(group string) (addrs []string, err error)

ConsumerAddrs returns consumer addrs.

func Init

func Init(c *conf.Config, s *service.Service)

Init init service

Types

type Pub

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

Pub databus producer

func NewPub

func NewPub(c *conn, group, topic, color string, pCfg *conf.Kafka) (p *Pub, err error)

NewPub new databus producer http 接口复用此方法,c 传 nil

func (Pub) Close

func (ps Pub) Close(sendRedisErr bool)

Close 跟 redis 协议耦合的太紧,加个 sendRedisErr 开关

func (Pub) Closed

func (ps Pub) Closed() bool

func (*Pub) Publish

func (p *Pub) Publish(key, header, value []byte) (partition int32, offset int64, err error)

Publish 发送消息 redis 和 http 协议共用

func (*Pub) Serve

func (p *Pub) Serve()

Serve databus producer goroutine

type Sub

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

Sub databus consumer

func NewSub

func NewSub(c *conn, group, topic, color string, sCfg *conf.Kafka, batch int64) (s *Sub, err error)

NewSub new databus consumer

func (*Sub) Close

func (s *Sub) Close()

Close close consumer

func (*Sub) Closed

func (s *Sub) Closed() bool

Closed judge if consumer is closed

func (*Sub) Serve

func (s *Sub) Serve()

Serve databus consumer goroutine

func (*Sub) WaitClosing

func (s *Sub) WaitClosing()

WaitClosing marks closing state and close when consumer stoped until 30s.

Jump to

Keyboard shortcuts

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