echo

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: MIT Imports: 6 Imported by: 1

README

echo

echo is a golang runtime message tool currently support 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)

use suber to make multi sub

suber := echo.NewSuber()
suber.Add(CHANNEL,CONSUMER)
suber.Sub(ctx)

Documentation

Index

Constants

View Source
const (
	BoolTrue  = "True"
	BoolFalse = "False"
)

Variables

This section is empty.

Functions

func GetBoolValue added in v0.0.11

func GetBoolValue(k string) (bool, error)

func GetJsonValue added in v0.0.11

func GetJsonValue(k string, data interface{}) error

func GetValue added in v0.0.11

func GetValue(k string) (string, error)

func Pub

func Pub(channel string, val string) error

pub string data to channel

func PubBool added in v0.0.11

func PubBool(channel string, val bool) error

pub bool data to channel

func PubBoolQ added in v0.0.11

func PubBoolQ(channel string, data bool)

func PubJson

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

pub json encoded data

func PubJsonQ added in v0.0.11

func PubJsonQ(channel string, data interface{}) error

func PubQ added in v0.0.11

func PubQ(channel string, data string)

func RemValue added in v0.0.11

func RemValue(k string)

func SetBoolValue added in v0.0.11

func SetBoolValue(k string, v bool)

func SetBuffer added in v0.0.10

func SetBuffer(count int)

func SetJsonValue added in v0.0.11

func SetJsonValue(k string, data interface{})

func SetValue added in v0.0.11

func SetValue(k string, v string)

func Sub

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

sub to some channel and take action

Types

type JobHandler added in v0.0.11

type JobHandler func(*SubCtx)

type Queue added in v0.0.11

type Queue struct {
	Stream chan string
}

func (*Queue) Append added in v0.0.11

func (q *Queue) Append(data string) error

func (*Queue) AppendBool added in v0.0.11

func (q *Queue) AppendBool(data bool) error

func (*Queue) AppendJson added in v0.0.11

func (q *Queue) AppendJson(data interface{}) error

func (*Queue) Consume added in v0.0.11

func (q *Queue) Consume(ctx context.Context, consumer func(*SubCtx))

type Streamer added in v0.0.11

type Streamer struct {
	QueueHandler map[string]func(*SubCtx)
}

func NewStreamer added in v0.0.11

func NewStreamer() *Streamer

func (*Streamer) Add added in v0.0.11

func (s *Streamer) Add(name string, handler JobHandler)

func (*Streamer) Stream added in v0.0.11

func (s *Streamer) Stream(ctx context.Context)

type SubCtx

type SubCtx struct {
	Value
}

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)

type Value added in v0.0.11

type Value struct {
	Data string
}

func (*Value) GetBool added in v0.0.11

func (v *Value) GetBool() bool

func (*Value) GetData added in v0.0.11

func (v *Value) GetData() string

func (*Value) GetJsonData added in v0.0.11

func (v *Value) GetJsonData(data interface{}) error

func (*Value) SetBool added in v0.0.11

func (v *Value) SetBool(data bool)

func (*Value) SetJson added in v0.0.11

func (v *Value) SetJson(data interface{}) error

func (*Value) SetValue added in v0.0.11

func (v *Value) SetValue(data string)

Jump to

Keyboard shortcuts

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