Description
A wrapper around gorilla websocket that can channelize the websocket messages. It gives the client this option to receive events in different channels. Channelize is useful when your websocket server is reading different types of events from a message broker. e.g., you might have multiple kafka topics or NATs subjects.
Channelize gives you this option to categorize the outbound messages. You can choose a name for each event type and register them as a channel in the Channelize and send messages to those channels. Then client can subscribe to one or more channels to receive the streams.
channelize alternatives and similar packages
Based on the "Go Tools" category.
Alternatively, view channelize alternatives based on common mentions on social networks and blogs.
-
The Go Play Space
Advanced Go Playground frontend written in Go, with syntax highlighting, turtle graphics mode, and more -
Sonic
Sonic is a Go library for network and I/O programming that provides developers with a consistent asynchronous model, with a focus on achieving the lowest possible latency and jitter in Go. -
typex
[TOOL/CLI] - Filter and examine Go type structures, interfaces and their transitive dependencies and relationships. Export structural types as TypeScript value object or bare type representations. -
Viney's go-cache
A flexible multi-layer Go caching library to deal with in-memory and shared cache by adopting Cache-Aside pattern. -
gothanks
GoThanks automatically stars Go's official repository and your go.mod github dependencies, providing a simple way to say thanks to the maintainers of the modules you use and the contributors of Go itself. -
go-lock
go-lock is a lock library implementing read-write mutex and read-write trylock without starvation -
goroutines
It is an efficient, flexible, and lightweight goroutine pool. It provides an easy way to deal with concurrent tasks with limited resource. -
PDF to Image Converter Using Golang
This project will help you to convert PDF file to IMAGE using golang. -
go-james
DISCONTINUED. James is your butler and helps you to create, build, debug, test and run your Go projects -
docs
Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard -
rescached
DISCONTINUED. [mirror] Resolver (DNS) cache daemon. See https://sr.ht/~shulhan/rescached [Moved to: https://github.com/shuLhan/rescached] -
Goenv
DISCONTINUED. ๐บ Manage Your Applications Go Environment. [Moved to: https://github.com/Clivern/Goenv] -
modver
Compare two versions of a Go module to check the version-number change required (major, minor, or patchlevel), according to semver rules. -
IP2Location.io Command Line
IP2Location.io command line to query IP geolocation data from IP2Location.io API -
IP2Location.io SDK
IP2Location.io Go SDK allows user to query for an enriched data set based on IP address and provides WHOIS lookup api that helps users to obtain domain information.
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of channelize or a related project?
README
channelize
A wrapper around gorilla websocket that can channelize the websocket messages. It gives the client this option to receive events in different channels. Channelize is useful when your websocket server is reading different types of events from a message broker. e.g., you might have multiple kafka topics or NATs subjects.
Channelize gives you this option to categorize the outbound messages. You can choose a name for each event type and register them as a channel in the Channelize and send messages to those channels. Then client can subscribe to one or more channels to receive the streams.
[channelize](images/channelize.png?raw=true "channelize")
Table of Contents
Install
To use Channelize, first you should use go get
command to get the latest version of this library:
go get -u github.com/hmdsefi/channelize
Next step is importing channelize to your project:
import "github.com/hmdsefi/channelize"
How to use
To use Channelize, first you should know about the channel concept. A channel is a unique name for a stream of events that have the same type. A channel can be public or private. A public channel sends the outbound messages to the all available connections that subscribed to that channel. A private channel needs authentication, it sends the outbound messages to a specific connection that already subscribed to that private channel with a valid token.
Public channels
To use public channels, first you should register your public channels with one of the following functions:
channel := channelize.RegisterPublicChannel("my-public-channel")
channels := channelize.RegisterPublicChannels("my-public-channel1", "my-public-channel2")
Registering same channel more than once won't break anything. It will override the previous one. To send messages to the channels, you should create an instance of Channelize struct to be able to use the library APIs.
chlz := channelize.NewChannelize()
Then you can call the following function in your consumer function to send the messages to the proper channel:
err := chlz.SendPublicMessage(ctx, channel, message)
if err != nil {
return err
}
Channelize struct gives you this option to create your handler or using the handler that channelize creates for you. If you want to implement the handler by yourself, then you can use the following method:
connection := chlz.CreateConnection(ctx context.Context, wsConn *websocket.Conn, options ...conn.Option)
Or you can create the handler by calling the following method:
handler := chlz.MakeHTTPHandler(appCtx context.Context, upgrader websocket.Upgrader, options ...conn.Option)
To subscribe to one or more public channels, client should send the following message to the server:
{
"type": "subscribe",
"params": {
"channels": [
"my-public-channel1",
"my-public-channel2"
]
}
}
To unsubscribe one or more channels, client should send the following message to the server:
{
"type": "unsubscribe",
"params": {
"channels": [
"my-public-channel1"
]
}
}
Private channels
To use private channels, first you should register your private channels with one of the following functions:
channel := channelize.RegisterPrivateChannel("my-private-channel")
channels := channelize.RegisterPrivateChannels("my-private-channel1", "my-private-channel2")
Private channels need authentication. To provide authentication you should implement the function type that is defined
in auth
package:
type AuthenticateFunc func (token string) (*Token, error)
Then you should pass as an option to the Channelize constructor:
chlz := channelize.NewChannelize(channelize.WithAuthFunc(MyAuthFunc)))
You can use CreateConnection
or MakeHTTPHandler
to create the connection for the client just like public channels.
To send the message to the client you should use the following function:
err := chlz.SendPrivateMessage(ctx, channel, userID, message)
if err != nil {
return err
}
To subscribe to private channels, client should fill the token field with the proper value:
{
"type": "subscribe",
"params": {
"channels": [
"my-public-channel1",
"my-private-channel1"
],
"token": "618bb5b00161cbd68bc744b2ea84c96601d6705f31cc7d32e01c3371f6e7"
}
}
To unsubscribe, client can use the following message:
{
"type": "unsubscribe",
"params": {
"channels": [
"my-private-channel1"
]
}
}
License
MIT License, please see LICENSE for details.
*Note that all licence references and agreements mentioned in the channelize README section above
are relevant to that project's source code only.