1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-10-31 20:14:21 +00:00
Commit graph

29 commits

Author SHA1 Message Date
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
diamondburned 7f4daccd2d
shard: Separate state's cabinet, fix return bugs
This commit makes it so that all sharded state.State instances will have
its own cabinet store on construction. This ensures that when a State is
reconnected, a Ready event won't wipe the cabinet for all other states.

This commit also fixes a bug with the Shard() and FromGuildID() getters.
2021-10-31 13:10:34 -07:00
diamondburned 5b328bdab0 shard: Remake shard manager (#226) 2021-06-14 15:22:55 -07:00
Samuel Hernandez 40e1a3757d *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00
Maximilian von Lindern 8a7c6c48a7 session,bot: Remove references to CloseGracefully and use Close instead 2021-05-29 22:18:05 -07:00
diamondburned ac2f3ba68a Bot: Close gracefully by default 2021-01-29 23:25:15 -08:00
diamondburned 81b1a0a902 Session: Added a handleloop abstraction
This abstraction will mainly be in charge of handling events from a
channel and dispatching them to handlers in a thread safe manner. It
boxes synchronizing mechanisms inside a struct.
2020-11-17 12:15:05 -08:00
diamondburned 6cbe95d2b3 State: Fixed erroneous context setting and races in Ready 2020-11-14 15:30:18 -08:00
diamondburned 75df94d9f4 *: Migrated Go Modules to v2 2020-10-28 15:39:59 -07:00
diamondburned 86795e42a6 Session: Fixed a potential race condition on Close 2020-10-21 22:42:16 -07:00
mavolin ba4b224168 handler: move package from /handler to /utils/handler 2020-07-29 16:58:33 -07:00
diamondburned edb8a46ef2 Gateway: Added intent helpers and more context API support 2020-07-11 12:50:32 -07:00
diamondburned (Forefront) 16ed406c53 Session: Fixed a panic bug when the gateway fails 2020-06-29 11:00:07 -07:00
Maximilian von Lindern de3d0e2160
Gateway: Split GuildCreateEvent (#116)
* Session: fix event handler loop not getting properly closed

* Implement #113

* Session: move guild events to state

* Session: close hStop
2020-06-06 13:47:15 -07:00
mavolin 41ce1f389e
make all error messages lowercase 2020-05-16 23:14:49 +02:00
diamondburned (Forefront) 2afe683b7d Utils: Added HTTP drivers 2020-04-19 14:53:53 -07:00
diamondburned (Forefront) 4e4ebde93a Gateway: Deprecated Wait(), fixed ReconnectOP bug 2020-04-12 11:06:43 -07:00
diamondburned (Forefront) 2f597ebc0b Session: Added an AfterClose handler as a *session.Close event 2020-04-06 19:36:06 -07:00
diamondburned (Forefront) 33061e916f Gateway: Now waits for either READY or RESUMED before finishing Open() 2020-04-06 13:27:33 -07:00
diamondburned (Forefront) f0102d765f Gateway: Added a retry limit
State: Event handlers now handle all of Ready's Guilds field
Session: Added Wait, which blocks until SIGINT or Gateway error
2020-02-29 18:13:58 -08:00
diamondburned (Forefront) 4e9bd53b0f Gateway: Added extra events 2020-02-15 21:29:25 -08:00
diamondburned (Forefront) ac685b0df4 Minor fixes, undocumented things, and editorconfig 2020-01-19 13:54:16 -08:00
diamondburned (Forefront) 7f06d88d0f Updated heartbeat behavior 2020-01-18 22:22:03 -08:00
diamondburned 2dc983d243 Added simple example 2020-01-17 14:29:13 -08:00
diamondburned (Forefront) deafe15967 Moved internal/handler outside 2020-01-16 21:23:56 -08:00
diamondburned (Forefront) d627690835 Added session, started state 2020-01-16 21:17:46 -08:00
diamondburned (Forefront) 4a529dd2ec Added Session + Handlers 2020-01-16 18:08:03 -08:00
diamondburned 127c636310 Moved misc packages to internal 2020-01-15 10:32:54 -08:00
diamondburned 8fc7229c3f
Added an untested Gateway package 2020-01-14 20:43:34 -08:00