diamondburned / arikawa

A Golang library and framework for the Discord API.
ISC License
483 stars 57 forks source link

v4: Redesign shard.Manager #342

Open diamondburned opened 2 years ago

diamondburned commented 2 years ago

In v4, at the very least, shard.Manager should now be generic.

Since we already have an interface for it, we can do this:

type Manager[S Shard] struct{}

func NewManager[S](idData gateway.IdentifyCommand, fn NewShardFunc[S]) (*Manager[S], error)

It might also be worth to consider redesigning Manager to a single instance that exposes an event channel, then wrap it inside another instance that dispatches those events to each shard instance.

We can then have state wrap the shard manager and provide its own states internally. This will avoid interfaces entirely.

switchupcb commented 2 years ago

Would you be interested in implementing a Shard Manager for Disgo?

diamondburned commented 2 years ago

I don't use Disgo.

diamondburned commented 2 years ago

@switchupcb This is irrelevant to the issue so I'll try to keep it short, but do you have an intermediate format (like jsonschema) for your dasgo?

I'm been interested in generating the bulk of Arikawa's API structures, but a lot of it cannot be autogenerated using regular codegens, so I've been looking to write a custom solution that can generate code from some schema.

switchupcb commented 1 year ago

I am unfamiliar with jsonschema, but it provides metadata about the JSON object type. As a result, you are requesting a code generator that parses every dasgo object and allows you to generate code based on the structs. copygen is a type-based code generator that allows you to specify types to parse, then create code generators for them accordingly.

If you need any more help, feel free to let me know.

diamondburned commented 1 year ago

As a result, you are requesting a code generator that parses every dasgo object and allows you to generate code based on the structs.

Ah well. I guess I have to parse the Go code, then. That's a bummer for me.

switchupcb commented 1 year ago

If you plan to use Dasgo let me know or add me on Discord. I will add your arikawa maintainers to the maintainer list.