1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-01 04:24:19 +00:00
arikawa/api
diamondburned 17b9c73ce3
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-11-25 14:46:41 -08:00
..
rate *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00
webhook discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
api.go api: Add support for the X-Audit-Log-Reason header (#259) 2021-08-15 18:33:33 +02:00
api_test.go API: Added WithContext API, closes #15 2020-05-03 14:02:03 -07:00
application.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
bot.go gateway: Refactor for a better concurrent API 2021-11-25 14:46:41 -08:00
channel.go api: *Client.ActiveThreads returns ActiveThreads struct (#270) 2021-08-20 02:27:53 -07:00
emoji.go api: Add support for the X-Audit-Log-Reason header (#259) 2021-08-15 18:33:33 +02:00
guild.go option: Move conflicting types into package discord 2021-08-30 13:23:43 -07:00
image.go *: Rename error types to have Error suffix (#215) 2021-06-06 12:40:24 -07:00
integration_test.go api: More multiple embed support for send functions (#266) 2021-08-16 02:26:25 -07:00
interaction.go api: Fix CreateInteractionFollowup return 2021-11-23 22:53:27 -08:00
invite.go api: Add support for the X-Audit-Log-Reason header (#259) 2021-08-15 18:33:33 +02:00
login.go *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00
member.go api: Remove Client.Kick and rename .KickWithReason to .Kick 2021-08-18 11:31:16 -07:00
message.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
message_reaction.go api: Add support for the X-Audit-Log-Reason header (#259) 2021-08-15 18:33:33 +02:00
role.go option: Move conflicting types into package discord 2021-08-30 13:23:43 -07:00
search.go api: Omitted SearchData redundant option type 2021-06-26 17:04:00 -07:00
send.go discord: Refactor interactions and components 2021-11-12 11:38:36 -08:00
send_test.go api: Update sending/editing messages for v9 (#230) 2021-06-17 23:32:11 -07:00
stage.go api: Add support for the X-Audit-Log-Reason header (#259) 2021-08-15 18:33:33 +02:00
user.go discord: Add per-guild avatars, ModifyMe -> ModifyCurrentUser (#278) 2021-09-28 11:46:36 -07:00
webhook.go *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00