evnt

package
v0.0.0-...-eaebcad Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 18 Imported by: 0

README

evnt package
PG driven event server

Documentation

Index

Constants

View Source
const (
	CMD_PUBLISH_ARGS = `{"argv":{"id":"%s"%s}}`
	CMD_PUBLISH_FN   = "Event.publish"
	QUERY_PAUSE_MS   = 50

	EVNT_PARAM_EMITTER_ID = "emitterId"
	EVNT_MODEL_ID         = "Event"
)

Variables

This section is empty.

Functions

func NewClientSocket

func NewClientSocket(conn net.Conn, token string, tokenExp time.Time, srv EventServer) socket.ClientSocketer

id string, ID: id,

Types

type AddEventProto

type AddEventProto = func(string, chan string)

type Event

type Event struct {
	Id     string                 `json:"id" required:"true" length:100`
	Params map[string]interface{} `json:"params"`
}

Common structure for subscribe/unsubscribe fields.ValAssocArray

type EventServer

type EventServer interface {
	CloseSocket(*EvntSocket)
}

type Event_Controller

type Event_Controller struct {
	gobizap.Base_Controller
	EvntServer *EvntSrv
}

Controller

func NewController_Event

func NewController_Event() *Event_Controller

type Event_Controller_publish

type Event_Controller_publish struct {
	gobizap.Base_PublicMethod
}

************************************************************************************** Public method: publish

func (*Event_Controller_publish) Run

custom method

func (*Event_Controller_publish) Unmarshal

func (pm *Event_Controller_publish) Unmarshal(payload []byte) (reflect.Value, error)

Public method Unmarshal to structure

type Event_Controller_subscribe

type Event_Controller_subscribe struct {
	gobizap.Base_PublicMethod
	Contr *Event_Controller
}

************************************************************************************** Public method: subscribe

func (*Event_Controller_subscribe) Run

custom method

func (*Event_Controller_subscribe) Unmarshal

func (pm *Event_Controller_subscribe) Unmarshal(payload []byte) (reflect.Value, error)

Public method Unmarshal to structure

type Event_Controller_unsubscribe

type Event_Controller_unsubscribe struct {
	gobizap.Base_PublicMethod
	Contr *Event_Controller
}

************************************************************************************** Public method: unsubscribe

func (*Event_Controller_unsubscribe) Run

custom method

func (*Event_Controller_unsubscribe) Unmarshal

func (pm *Event_Controller_unsubscribe) Unmarshal(payload []byte) (reflect.Value, error)

Public method Unmarshal to structure

type Event_argv

type Event_argv struct {
	Argv *Event `json:"argv"`
}

type Event_subscr

type Event_subscr struct {
	Events []Event `json:"events" required:"true"`
}

subscribe fields.ValArray

type Event_subscr_argv

type Event_subscr_argv struct {
	Argv *Event_subscr `json:"argv"`
}

type EvntSocket

type EvntSocket struct {
	socket.ClientSocket
	Events *uniqSocketEvents //unique events for one client connection
	Srv    EventServer
}

Socket for one client events

func (*EvntSocket) Close

func (s *EvntSocket) Close()

func (EvntSocket) GetDescr

func (s EvntSocket) GetDescr() string

type EvntSrv

type EvntSrv struct {
	DbPool      *pgxpool.Pool //
	DbQuery     chan string   //for notification queries
	Events      *UniqEvents   //count of unique events for db
	Logger      logger.Logger
	LocalEvents map[string]bool

	QueryPauseMS    int
	ReconnectParams waitStrat.WaitStrategy

	OnEvent OnEventProto
	// contains filtered or unexported fields
}

event server params

func NewEvntSrv

func NewEvntSrv(logger logger.Logger, onEvent OnEventProto, localEvents []string) *EvntSrv

func (*EvntSrv) AddDbListener

func (s *EvntSrv) AddDbListener(dbEventID string, socket *EvntSocket)

adds listener

func (*EvntSrv) CloseSocket

func (s *EvntSrv) CloseSocket(socket *EvntSocket)

func (*EvntSrv) OnNotification

func (s *EvntSrv) OnNotification(_ *pgconn.PgConn, n *pgconn.Notification)

func (*EvntSrv) PublishEvent

func (s *EvntSrv) PublishEvent(evId, params string)

calls Event.Publish(args) params - comma separated string of json params

func (*EvntSrv) RemoveDbListener

func (s *EvntSrv) RemoveDbListener(dbEventID string, socket *EvntSocket)

removes listener

func (*EvntSrv) Run

func (s *EvntSrv) Run()

func (*EvntSrv) Shutdown

func (s *EvntSrv) Shutdown(ctx context.Context) error

type OnEventProto

type OnEventProto = func(string, []byte) //"ControllerID.MethodId", arguments

type RemoveEventProto

type RemoveEventProto = func(string, chan string)

type UniqEvents

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

func (*UniqEvents) AddEvent

func (e *UniqEvents) AddEvent(dbEventID string, qChan chan string)

func (*UniqEvents) GetEvent

func (e *UniqEvents) GetEvent(eventID string) (int, bool)

func (*UniqEvents) GetEventCount

func (e *UniqEvents) GetEventCount() int

func (*UniqEvents) RemoveEvent

func (e *UniqEvents) RemoveEvent(dbEventID string, qChan chan string)

Jump to

Keyboard shortcuts

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