event

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	EventPublished    EventStatus = "published"
	EventSubscribed   EventStatus = "subscribed"
	EventUnsubscribed EventStatus = "unsubscribed"
	EventReceived     EventStatus = "received"
	QUEUE_STACK                   = "stack"
	EVENT_STATUS                  = "event:status"
	EVENT_LOG                     = "event:log"
	EVENT_OVERFLOW                = "event:overflow"
	EVENT_WORK                    = "event:work"
	EVENT_WORK_STATE              = "event:work:state"
)
View Source
const PackageName = "event"

Variables

This section is empty.

Functions

func Close

func Close()

* * Close the connection to the service pubsub *

func Emiter added in v1.0.11

func Emiter(channel string, data et.Json)

* * emit * @param channel string, data et.Json *

func Error

func Error(event string, err error) error

* * Error * @param event string, * @return error *

func Events

func Events() []string

* * Events * @return []string *

func HealthCheck added in v0.1.18

func HealthCheck() bool

* * HealthCheck * @return bool *

func HttpEventPublish added in v0.1.17

func HttpEventPublish(w http.ResponseWriter, r *http.Request)

* * HttpEventPublish * @param w http.ResponseWriter, r *http.Request *

func Id added in v0.1.1

func Id() string

* * Id * @return string *

func Load

func Load() error

* * Load * @return error *

func Log

func Log(event string, data et.Json)

* * Log * @param event string, data et.Json *

func On

func On(channel string, handler Handler)

* * On * @param channel string, handler Handler *

func Overflow

func Overflow(data et.Json)

* * Overflow * @param data et.Json *

func Publish

func Publish(channel string, data et.Json) error

* * Publish * @param channel string, data et.Json * @return error *

func Queue

func Queue(channel, queue string, f func(Message)) (err error)

* * Queue * @param channel string, queue string, f func(Message) * @return error *

func Reset added in v0.1.17

func Reset() error

* * Reset * @return error *

func Source

func Source(channel string, f func(Message)) error

* * Source * @param channel string, f func(Message) * @return error *

func Stack

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

* * Stack * @param channel string, f func(Message) * @return error *

func State added in v1.0.11

func State(id string, status WorkStatus, data et.Json)

* * State * @param id string, status WorkStatus *

func Subscribe

func Subscribe(channel string, f func(Message)) (err error)

* * Subscribe * @param channel string, f func(Message) * @return error *

func Unsubscribe added in v0.0.2

func Unsubscribe(channel string) error

* * Unsubscribe * @param channel string * @return error *

func Work

func Work(event string, data et.Json) et.Json

* * Work * @param event string, data et.Json * @return et.Json *

Types

type Conn

type Conn struct {
	*nats.Conn
	// contains filtered or unexported fields
}

func ConnectTo

func ConnectTo(host, user, password string) (*Conn, error)

* * Connect to a host * @param host, user, password string * @return *Conn, error *

func (*Conn) Remove added in v0.1.17

func (s *Conn) Remove(event string) (bool, error)

* * Remove * @return error *

func (*Conn) Reset added in v0.1.17

func (s *Conn) Reset() error

* * Reset * @return error *

type EventEmiter

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

type EventStatus added in v1.0.11

type EventStatus string

type Handler

type Handler func(message Message)

type Message

type Message struct {
	CreatedAt time.Time `json:"created_at"`
	FromId    string    `json:"from_id"`
	Id        string    `json:"id"`
	Channel   string    `json:"channel"`
	Data      et.Json   `json:"data"`
	Myself    bool      `json:"myself"`
}

func DecodeMessage

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

* * DecodeMessage * @param []byte data * @return Message, error *

func NewEvenMessage

func NewEvenMessage(channel string, data et.Json) Message

* * NewEvenMessage * @param string channel * @param et.Json data * @return Message *

func (Message) Encode

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

* * Encode * @return []byte, error *

func (Message) Serialize added in v1.0.11

func (s Message) Serialize() ([]byte, error)

* * Serialize * @return []byte, error *

func (Message) ToJson

func (s Message) ToJson() (et.Json, error)

* * ToJson * @return et.Json, error *

func (Message) ToString

func (s Message) ToString() string

* * ToString * @return string *

type WorkStatus

type WorkStatus string
const (
	StatusPending    WorkStatus = "pending"
	StatusProcessing WorkStatus = "processing"
	StatusCompleted  WorkStatus = "completed"
	StatusFailed     WorkStatus = "failed"
)

Jump to

Keyboard shortcuts

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