example

module
v0.0.0-...-8162d1b Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT

README

Pubsub on websocket client server example

This repos tests Golang websockets and a simple in-memory pub/sub broker to share messages.

Usage

Install
go mod download
Run server
go run cmd/server/main.go

   ____    __
  / __/___/ /  ___
 / _// __/ _ \/ _ \
/___/\__/_//_/\___/ v4.10.2
High performance, minimalist Go web framework
https://echo.labstack.com
____________________________________O/_______
                                    O\
⇨ http server started on [::]:12345
Dashboard

The dashboard has been copied from GoogleCloud tutorial: Streaming Pub/Sub messages over WebSockets.

Open you browser to see dashboard localhost:12345

Click on the cab in the Dashcab title on top left corner.

Client

Run the client to send a fake cab course.

go run cmd/client/main.go

Then check the dashboard.

Development

Install air

go install github.com/cosmtrek/air@latest

Run watcher

air

  __    _   ___  
 / /\  | | | |_) 
/_/--\ |_| |_| \_ , built with Go 

watching .
watching cmd
watching cmd/client
watching cmd/server
watching internal
watching internal/pubsub
!exclude panel
!exclude tmp
building...
running...

   ____    __
  / __/___/ /  ___
 / _// __/ _ \/ _ \
/___/\__/_//_/\___/ v4.10.2
High performance, minimalist Go web framework
https://echo.labstack.com
____________________________________O/_______
                                    O\
⇨ http server started on [::]:12345

Directories

Path Synopsis
cmd
client command
server command

Jump to

Keyboard shortcuts

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