echo

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 License: MIT Imports: 7 Imported by: 1

README

echo

echo is a golang runtime message tool It's currently support message pub/sub

Install

go get github.com/johnhaha/echo

Usage

Pub
echo.Pub(CHANNEL,CONTENT)
Pub Json
echo.PubJson(CHANNEL,JSON)
Sub
echo.Sub(CONTEXT,CHANNEL,HANDLER)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pub

func Pub(channel string, val string) error

pub string data to channel

func PubJson

func PubJson(channel string, val interface{}) error

pub json encoded data

func Sub

func Sub(ctx context.Context, channel string, consumer func(*SubCtx))

sub to some channel and take action

Types

type SubCtx

type SubCtx struct {
	Data string
}

func (*SubCtx) Parser

func (c *SubCtx) Parser(data interface{}) error

type Suber added in v0.0.7

type Suber struct {
	SubMap map[string]func(*SubCtx)
}

func NewSuber added in v0.0.7

func NewSuber() *Suber

func (*Suber) Add added in v0.0.7

func (s *Suber) Add(channel string, consumer func(*SubCtx))

func (*Suber) Sub added in v0.0.7

func (s *Suber) Sub(ctx context.Context)

Jump to

Keyboard shortcuts

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