Events - Event Manager - Nodejs like

events

Event Manager - Nodejs like

Please take a look at the TESTS, for further comprehension.

Example

package main

import (
	"errors"
	"fmt"
	"log"

	"github.com/digitalcircle-com-br/events"
)

func main() {
	//ensure errors will be handled
	events.OnErr(func(e events.ErrMsg) {
		log.Printf("ERROR: %s\n%s", e.Err.Error(), string(e.Stack))
	})

	//reacts to event a
	events.On("a", func(s string) {
		log.Printf("(a) Got: " + s)
	})

	//reacts to event b
	events.On("b", func(s string) {
		log.Printf("(b) Got: " + s)
	})

	//fires some events
	for i := 0; i < 10; i++ {
		events.Fire("a", fmt.Sprintf("A: %v", i))
		events.Fire("b", fmt.Sprintf("B: %v", i))
	}
	err := errors.New("some")
	
	//This is why events.Err returns bool :)
	if events.Err(err) {
		//also handle your event in the flow...
		log.Printf("Got error: %s", err.Error())
	}
	
	events.CloseAll()
	//waits for events to end
	events.Wait()
}
Owner
Digital Circle
Digital Circle
Digital Circle
Similar Resources

Bell is the simplest event system written in Go (Golang) which is based on the execution of handlers independent of the main channel.

Bell Bell is the simplest event system written in Go (Golang) which is based on the execution of handlers independent of the main channel. Written in

Nov 17, 2022

Event Source for Direktiv and Knative

Event Source for Direktiv and Knative This repository contains ContainerSources for Knative Eventing. The following sources are available: Direktiv (I

Mar 13, 2022

Event driven modular status-bar for dwm; written in Go & uses Unix sockets for signaling.

dwmstat A simple event-driven modular status-bar for dwm. It is written in Go & uses Unix sockets for signaling. The status bar is conceptualized as a

Dec 25, 2021

An event driven remote access trojan for experimental purposes.

erat An event driven remote access trojan for experimental purposes. This example is very simple and leverages ssh failed login events to trigger erat

Jan 16, 2022

Eventproc - A proof-of-concept for exploring event based architecture utilizing bi-directional gRPC streams

eventproc A proof-of-concept for exploring event based architecture utilizing bi

Jan 25, 2022

A download manager package for Go

grab Downloading the internet, one goroutine at a time! $ go get github.com/cavaliercoder/grab Grab is a Go package for downloading files from the in

Jan 1, 2023

Protobuf files manager

Prot - protobuf files manager. It application can help your manage protobuf files and generate code based on him. !!! Before use Prot you must install

Jun 22, 2022

A flexible configuration manager for Wireguard networks

A flexible configuration manager for Wireguard networks

Drago A flexible configuration manager for WireGuard networks Drago is a flexible configuration manager for WireGuard networks which is designed to ma

Jan 7, 2023

High-performance PHP application server, load-balancer and process manager written in Golang

High-performance PHP application server, load-balancer and process manager written in Golang

RoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager. It supports running as a serv

Jan 1, 2023
Related tags
Package event-driven makes it easy for you to drive events between services
Package event-driven makes it easy for you to drive events between services

Event-Driven Event-driven architecture is a software architecture and model for application design. With an event-driven system, the capture, communic

Apr 20, 2022
OCM events management service

Events Service This project provides a service that gives access to events generated by the OCM services. Building Locally Cloning There is nothing sp

Oct 15, 2021
GSRPC compatible type definitions of events from the ChainBridge substrate pallet

chainbridge-substrate-events GSRPC compatible type definitions of events from the ChainBridge substrate pallet. ChainSafe Security Policy Reporting a

Nov 13, 2021
TCP output for beats to send events over TCP socket.

beats-tcp-output How To Use Clone this project to elastic/beats/libbeat/output/ Modify elastic/beats/libbeat/publisher/includes/includes.go : // add i

Aug 25, 2022
UDP output for beats to send events over UDP.

beats-udp-output How To Use Clone this project to elastic/beats/libbeat/output/ Modify elastic/beats/libbeat/publisher/includes/includes.go : // add i

Dec 11, 2021
🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go./ gnet 是一个高性能、轻量级、非阻塞的事件驱动 Go 网络框架。
🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go./ gnet 是一个高性能、轻量级、非阻塞的事件驱动 Go 网络框架。

English | ???? 中文 ?? Introduction gnet is an event-driven networking framework that is fast and lightweight. It makes direct epoll and kqueue syscalls

Jan 2, 2023
A pluggable backend API that enforces the Event Sourcing Pattern for persisting & broadcasting application state changes
A pluggable backend API that enforces the Event Sourcing Pattern for persisting & broadcasting application state changes

A pluggable "Application State Gateway" that enforces the Event Sourcing Pattern for securely persisting & broadcasting application state changes

Nov 1, 2022
Fast event-loop networking for Go
Fast event-loop networking for Go

evio is an event loop networking framework that is fast and small. It makes direct epoll and kqueue syscalls rather than using the standard Go net pac

Dec 31, 2022
High-performance, non-blocking, event-driven, easy-to-use networking framework written in Go, support tls/http1.x/websocket.

High-performance, non-blocking, event-driven, easy-to-use networking framework written in Go, support tls/http1.x/websocket.

Jan 8, 2023
Walrus 🕑 Real-time event streaming platform built on top of gRPC streams
Walrus 🕑 Real-time event streaming platform built on top of gRPC streams

Walrus ?? Real-time event streaming platform built on top of gRPC streams Table of Contents About the project Built With How it works Getting Started

Sep 24, 2022