nats

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERR_ENV_REQUIRED       = "Variables de entorno requerida (%s)"
	ERR_NOT_CONNECT        = "Not connect nats"
	ERR_PARAM_NOT_FOUND    = "Param not found"
	ERR_CLIENT_ID_EMPTY    = "Client id is empty"
	PARAMS_UPDATED         = "Params updated"
	ERR_NOT_PUBSUB_SERVICE = "PubSub service not found"
)

Variables

This section is empty.

Functions

func Close

func Close()

func Overflow

func Overflow(message interface{})

Send a overflow message

func Publish

func Publish(channel string, message interface{}) error

Publish a message to a channel

func Stack

func Stack(channel string, reciveFn func(Message)) error

func Subscribe

func Subscribe(channel string, reciveFn func(Message)) error

Subscribe to a channel

func Telemetry

func Telemetry(message interface{})

Send a telemetry message

func TokeLastUse

func TokeLastUse(message interface{})

Send a token last use message

Types

type Conn

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

func Load

func Load() (*Conn, error)

type Message

type Message struct {
	Created_at time.Time `json:"created_at"`
	Id         string    `json:"id"`
	From       js.Json   `json:"from"`

	Tp      message.TpMessage `json:"tp"`
	Channel string            `json:"channel"`
	Data    interface{}       `json:"data"`
	// contains filtered or unexported fields
}

func DecodeMessage

func DecodeMessage(data []byte) (Message, error)

Decode return the message as struct

func NewMessage

func NewMessage(from js.Json, message interface{}) Message

NewMessage create a new message

func (Message) Encode

func (e Message) Encode() ([]byte, error)

Encode return the message as byte

func (Message) Json

func (e Message) Json() (js.Json, error)

Json return the message as json

func (Message) ToString

func (e Message) ToString() string

ToString return the message as string

func (Message) Type

func (e Message) Type() message.TpMessage

Type return the type of message

type PubSub

type PubSub struct {
	ClientId string
	Name     string
	// contains filtered or unexported fields
}

func NewPubSub

func NewPubSub() (*PubSub, error)

Create a new client websocket connection

func (*PubSub) Close

func (p *PubSub) Close()

Close the client websocket connection

func (*PubSub) Connect

func (p *PubSub) Connect() (bool, error)

Connect to the server

func (*PubSub) IsConnected

func (p *PubSub) IsConnected() bool

Check if the client is connected

func (*PubSub) Params

func (p *PubSub) Params(params js.Json) error

Set the client parameters

func (*PubSub) Ping

func (p *PubSub) Ping()

Ping the server

func (*PubSub) Publish

func (p *PubSub) Publish(channel string, message interface{})

Publish a message to a channel

func (*PubSub) SendMessage

func (p *PubSub) SendMessage(clientId string, message interface{}) error

Send a message to the server

func (*PubSub) Stack

func (p *PubSub) Stack(channel string, reciveFn func(m.Message))

Subscribe to a channel type fisrt, so send message to first client

func (*PubSub) Subscribe

func (p *PubSub) Subscribe(channel string, reciveFn func(m.Message))

Subscribe to a channel

func (*PubSub) Type

func (p *PubSub) Type() string

Return type server pubsub

func (*PubSub) Unsubscribe

func (p *PubSub) Unsubscribe(channel string)

Unsubscribe from a channel

Jump to

Keyboard shortcuts

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