Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DefaultGateway open #733

Open
WinteryFox opened this issue Nov 27, 2022 · 4 comments
Open

Make DefaultGateway open #733

WinteryFox opened this issue Nov 27, 2022 · 4 comments

Comments

@WinteryFox
Copy link
Contributor

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(?)

@lukellmann
Copy link
Member

lukellmann commented Nov 28, 2022

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")
}

@WinteryFox
Copy link
Contributor Author

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

@lukellmann
Copy link
Member

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.)

@WinteryFox
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants