centrifugal / centrifuge

Real-time messaging library for Go. The simplest way to add feature-rich and scalable WebSocket support to your application. The core of Centrifugo server.

Home Page:https://pkg.go.dev/github.com/centrifugal/centrifuge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate possibility to get rid of ChannelOptionFunc

FZambia opened this issue · comments

Looks like we can move channel feature control to method calls and to event handler replies. This will make things more flexible and obvious.

The plan is as follows:

HistorySize and HistoryLifetime can be set as Publish call options. Actually, this is already true (though lifetime managed over HistoryTTL and has time.Duration type).

HistoryRecover, Presence, JoinLeave options can be set in SubscribeReply.

The tricky thing is that Publish, History, Presence, PresenceStatsclient protocol handlers at moment return results by internally calling corresponding node methods. To achieve our goal here we have to avoid running operations automatically by Centrifuge and leave this for a library user. I.e. developer will have to call Publish himself in OnPublish handler and provide corresponding history options if needed. Then return PublishResult. Similar for History, Presence, PresenceStats calls.

Done in v0.13.0