event

package
v1.1.196 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	EVENT            = "event"
	EVENT_LOG        = "event:log"
	EVENT_OVERFLOW   = "event:requests:overflow"
	EVENT_WORK       = "event:worker"
	EVENT_WORK_STATE = "event:worker:state"
	EVENT_SUBSCRIBED = "event:subscribed"
	EVENT_SOURCE     = "event:source"
)
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"
	ERR_CHANNEL_REQUIRED = "channel is required"
	PARAMS_UPDATED       = "Params updated"
)
View Source
const QUEUE_STACK = "stack"

Variables

This section is empty.

Functions

func Close

func Close()

* * Close * @return void *

func Emit added in v1.1.82

func Emit(channel string, data et.Json)

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

func HealthCheck added in v1.1.124

func HealthCheck() bool

* * HealthCheck * @return bool *

func HttpEventWork added in v1.1.0

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

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

func Id added in v1.1.81

func Id() string

* * Id * @return string *

func Log

func Log(event string, data et.Json)

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

func On added in v1.1.82

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(EvenMessage)) error

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

func Source

func Source(model, action string, data et.Json) et.Json

* * Source * @param string model, string action, string err, data et.Json * @return error *

func Stack

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

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

func Subscribe

func Subscribe(channel string, f func(EvenMessage)) error

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

func Unsubscribe added in v1.1.142

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 *

func WorkState

func WorkState(work_id string, status WorkStatus, data et.Json)

* * WorkState * @param work_id string, status WorkStatus, data et.Json *

Types

type Conn

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

func ConnectTo added in v1.1.30

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

* * ConnectTo * @param host, user, password string * @return *Conn, error *

func Load

func Load() (*Conn, error)

* * Load * @return *Conn, error *

func (*Conn) Add added in v1.1.108

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

* * Save * @return error *

func (*Conn) Remove added in v1.1.108

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

* * Remove * @return error *

type EvenMessage

type EvenMessage struct {
	Created_at 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:"my_self"`
}

func DecodeMessage

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

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

func NewEvenMessage

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

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

func (EvenMessage) Encode

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

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

func (EvenMessage) ToJson

func (m EvenMessage) ToJson() (et.Json, error)

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

func (EvenMessage) ToString

func (m EvenMessage) ToString() string

* * ToString * @return string *

type EventEmiter added in v1.1.82

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

func NewEventEmiter added in v1.1.82

func NewEventEmiter() *EventEmiter

* * NewEventEmiter * @return *EventEmiter *

func (*EventEmiter) Emit added in v1.1.82

func (s *EventEmiter) Emit(channel string, data et.Json)

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

func (*EventEmiter) On added in v1.1.82

func (s *EventEmiter) On(channel string, handler Handler)

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

func (*EventEmiter) Start added in v1.1.82

func (s *EventEmiter) Start()

* * Start *

type Handler added in v1.1.82

type Handler func(message EvenMessage)

type Message

type Message interface {
	Type() string
}

type WorkStatus

type WorkStatus int
const (
	WorkStatusPending WorkStatus = iota
	WorkStatusAccepted
	WorkStatusProcessing
	WorkStatusCompleted
	WorkStatusFailed
)

func ToWorkStatus

func ToWorkStatus(n int) WorkStatus

* * ToWorkStatus * @param int n * @return WorkStatus *

func (WorkStatus) String

func (s WorkStatus) String() string

* * String * @return string *

Jump to

Keyboard shortcuts

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