1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-28 09:42:58 +00:00
arikawa/discord
diamondburned 54cadd2f45 gateway: Refactor for a better concurrent API
This commit refactors the whole package gateway as well as utils/ws
(formerly utils/wsutil) and voice/voicegateway. The new refactor
utilizes a design pattern involving a concurrent loop and an arriving
event channel.

An additional change was made to the way gateway events are typed.
Before, pretty much any type will satisfy a gateway event type, since
the actual type was just interface{}. The new refactor defines a
concrete interface that events can implement:

    type Event interface {
        Op() OpCode
        EventType() EventType
    }

Using this interface, the user can easily add custom gateway events
independently of the library without relying on string maps. This adds a
lot of type safety into the library and makes type-switching on Event
types much more reasonable.

Gateway error callbacks are also almost entirely removed in favor of
custom gateway events. A catch-all can easily be added like this:

    s.AddHandler(func(err error) {
        log.Println("gateway error:, err")
    })
2021-12-14 13:49:34 -08:00
..
application.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
auditlog.go *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00
channel.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
command.go discord: Fix incorrect Min/Max fields in command.go 2021-12-02 13:21:47 -08:00
component.go discord: Improve union interface documentation; fix *Option JSON 2021-11-25 15:02:24 -08:00
discord.go Discord: optimize struct sizes; add missing fields 2020-11-22 09:16:24 -08:00
emoji.go discord: Emoji methods use IsUnicode() 2021-05-29 14:16:44 -07:00
guild.go discord: Fix json tag for Guild.Features (#283) 2021-10-04 23:22:27 -07:00
guild_consts.go api: Threads (#257) 2021-08-08 13:19:15 -07:00
interaction.go discord: Improve union interface documentation; fix *Option JSON 2021-11-25 15:02:24 -08:00
invite.go
message.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
message_embed.go option: Move conflicting types into package discord 2021-08-30 13:23:43 -07:00
permission.go discord: Update to match current API docs (#277) 2021-09-23 21:37:50 -07:00
snowflake.go gateway: Refactor for a better concurrent API 2021-12-14 13:49:34 -08:00
snowflake_test.go
snowflake_types.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
stage.go discord/api: Add StageInstances 2021-05-29 22:17:39 -07:00
time.go discord: Add VoiceState.SelfVideo; fixes #287 2021-10-30 16:43:28 -07:00
url.go
user.go discord: Minor comment tweaks 2021-11-16 14:36:07 -08:00
voice.go discord: Add VoiceState.SelfVideo; fixes #287 2021-10-30 16:43:28 -07:00
webhook.go discord: Add missing webhook fields (#250) 2021-08-02 16:14:34 -07:00