kordlib/kord

Make DefaultGateway open

WinteryFox opened this issue · 4 comments

In order to use my own queue system (in my case with RabbitMQ) I would like to intercept gateway events and put them into my own queues. Unfortunately DefaultGateway is not an open class and thus cannot be extended and overwritten. Ideally there should also be some kind of way to inject events into the Gateway from outside sources (like RabbitMQ), though this might already be possible(?)

Maybe I don't understand this right, but isn't delegation enough for your usecase?

class YourGateway(private val delegate: Gateway) : Gateway by delegate {
    override val events: SharedFlow<Event> = TODO("use 'delegate.events' and intercept/transform as needed")
}

No because this doesn't give me access to the raw payloads from the gateway, which is what I want.

Ok, then I didn't understand this right.

But just making DefaultGateway an open class also wouldn't solve this, the class wasn't designed for inheritance so there aren't any methods that could be overwritten in a meaningful way.

So to support usecases like yours, we would need some major design work to avoid a half-baked solution.

If you want full control over the gateway and raw payloads you can always implement your own Gateway from scratch. (However this isn't easy.)

Implementing my own is exactly what I'm trying to avoid doing. Ideally there would be some kind of system built into Kord that can do stuff like queueing gateway events and then also read them from that queue again. However in the interest of time a temporary half-baked solution is what I'm after right now.