Just a PubSub Websocket Server

Eventual Agent

Just a PubSub Websocket Server

The eventual agent allows cluster local apps to subscribe and publish over network.

Goals

  • Provide a WebSocket server for handling Pubsub for cloudevents
  • Simple with small footprint

Interface

interface EventualMessage {
  type: "publish" | "subscribe" | "unsubscribe"
}

// Payload for both subscribing and unsubscribing to/from channels
interface SubscribeMessage extends EventualMessage {
  channels: string | string[]
}

// Format of a publish message payload
interface PublishMessage extends EventualMessage {
  channels: string | string[]
  event: ICloudEvent
}

interface ICloudEvent<T = any> {
  specversion: '1.0'
  type: string // 'com.example.someevent'
  source: string // '/mycontext'
  id: string // uuid
  time: string // '2018-04-05T17:31:00Z'
  datacontenttype: 'application/json'
  data: T
  meta?: ObjectLiteral
  [key: string]: string | number | ObjectLiteral | undefined
}

Choices


Option 1:

Client owned subscriptions?

{ [clientId]: [subscriptions] } 
Pros:
  • Quick lookup for a specific clients subscriptions
Cons:
  • Slower to check if client is subscribed to a specific channel or not

Option 2:

Clients subscribe to channels?

{  [channelName]: [clientIds]  }
Pros:
  • Quick to lookup all clients subscribed to a channel
Cons:
  • Slow to check all subscribed channels to by a client

Decision

Decided Option 2, as I dont care about looking up all subscriptions for a specific client, but care about fast lookup of all client subscribed to a specific channel for quick publishing.

Implementation

Written in golang for simplicity, minimal footprint and faster processing

type PublishEvent struct {
	Type     string        `json:"type"`
	Channels []interface{} `json:"channels"`
	Event    CloudEvent `json:"event"`
}

type SubscribeMessage struct {
	Type     string        `json:"type"`
	Channels []interface{} `json:"channels"`
}

type CloudEvent struct {
	Id              string      `json:"id"`
	Source          string      `json:"source"`
	Type            string      `json:"type"`
	Data            interface{} `json:"data"`
	DataContentType string      `json:"datacontenttype"`
	Time            int         `json:"time"`
	SpecVersion     string      `json:"specversion"`
}

CloudEvents.io https://github.com/cloudevents/spec/blob/v1.0.1/spec.md

Owner
Joshua Tracey
Software Engineer
Joshua Tracey
Similar Resources

WebSocket Command Line Client written in Go

ws-cli WebSocket Command Line Client written in Go Installation go get github.com/kseo/ws-cli Usage $ ws-cli -url ws://echo.websocket.org connected (

Nov 12, 2021

proxy your traffic through CDN using websocket

go-cdn2proxy proxy your traffic through CDN using websocket what does it do example server client thanks what does it do you can use this as a library

Dec 7, 2022

Chat bots (& more) for Zoom by figuring out their websocket protocol

Chat bots (& more) for Zoom by figuring out their websocket protocol

zoomer - Bot library for Zoom meetings Good bot support is part of what makes Discord so nice to use. Unfortunately, the official Zoom API is basicall

Dec 14, 2022

Tiny WebSocket library for Go.

RFC6455 WebSocket implementation in Go.

Dec 28, 2022

Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Go Example for TurboStreams over WebSockets Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Dec 22, 2022

Minimal and idiomatic WebSocket library for Go

websocket websocket is a minimal and idiomatic WebSocket library for Go. Install go get nhooyr.io/websocket Highlights Minimal and idiomatic API First

Dec 31, 2022

:notes: Minimalist websocket framework for Go

:notes: Minimalist websocket framework for Go

melody 🎶 Minimalist websocket framework for Go. Melody is websocket framework based on github.com/gorilla/websocket that abstracts away the tedious p

Dec 23, 2022

A modern, fast and scalable websocket framework with elegant API written in Go

A modern, fast and scalable websocket framework with elegant API written in Go

About neffos Neffos is a cross-platform real-time framework with expressive, elegant API written in Go. Neffos takes the pain out of development by ea

Dec 29, 2022

Terminal on browser via websocket

Terminal on browser via websocket. Supportted OS Linux Mac

Dec 27, 2022
Encrypted-websocket-chat - Encrypted websocket chat using golang

Encrypted websocket chat First version written in python This version should be

Sep 15, 2022
Websocket-chat - A simple websocket chat application
Websocket-chat - A simple websocket chat application

WebSocket Chat App This is a simple chat app based on websockets. It allows user

Jan 25, 2022
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.

websocketd websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSoc

Dec 31, 2022
BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication.

BrisGolang BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication. Usage You can play

Nov 1, 2021
HLive is a server-side WebSocket based dynamic template-less view layer for Go.
HLive is a server-side WebSocket based dynamic template-less view layer for Go.

HLive HLive is a server-side WebSocket based dynamic template-less view layer for Go. HLive is a fantastic tool for creating complex and dynamic brows

Jan 8, 2023
Websocket server, implemented flow Room style

ignite A websocket server module. Require redis to scale to multi nodes. Client/server message follow format type Message struct { Event string

Apr 10, 2022
API that upgrades connection to use websocket. Contains server and client and testing how they communicate

Websocket Test API How to execute First run server using: make run-server. Then run many client instances with: make run-client. Then start typing in

Dec 25, 2021
Websocket server. Get data from provider API, clean data and send to websoket, when it's changed.

Описание Сервис получает данные по киберспортивным матчам CS:GO от провайдера, структурирует, очищает от лишнего и отправляет всем активным вебсокет к

Apr 6, 2022
A simple server to convert ATK-IMU901 serial data into websocket stream

A simple server to convert ATK-IMU901 serial data into WebSocket stream.

Jan 31, 2022
A fast, well-tested and widely used WebSocket implementation for Go.

Gorilla WebSocket Gorilla WebSocket is a Go implementation of the WebSocket protocol. Documentation API Reference Chat example Command example Client

Jan 2, 2023