1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-05 06:26:08 +00:00
Commit graph

90 commits

Author SHA1 Message Date
Samuel Hernandez 40e1a3757d *: Migrated Go Modules to v3 2021-06-01 19:59:01 -07:00
Maximilian von Lindern a3a3f5a1b8 wsutil: Make wsutil.GracefulCloser part of wsutil.Connection 2021-05-29 22:17:49 -07:00
unknown 3b212908a5 utils: Change Enum to int32 2021-05-29 14:16:44 -07:00
Maximilian von Lindern ebc74e3168
Gateway: Sharding callback, proper closing (#190)
* Gateway: Fix gateway reconnect

This commit uses the correct timeout, Gateway.ReconnectTimeout, when reconnecting. Furthermore, it adds a delay between consecutive, failed reconnects.

* Gateway: Stop pacemaker when calling Gateway.CloseGracefully

* API: remove unnecessary leading/trailing whitespaces

* Gateway: Add Gateway.OnScalingRequired callback

* Gateway: Make all user initiated user closures graceful and ensure that closures are respected during reconnects

* Gateway: Fix typo

* Gateway: Add Gateway.ReconnectAttempts and deprecate .ReconnectTimeout

* Gateway: Add Gateway.Pause and reexport .Reconnect and .ReconnectCtx

* Gateway: Improve the Gateway.OnShardingRequired docs

* Wsutil: Code cleanup
2021-04-07 11:38:26 -07:00
diamondburned f5dc90c2d4 API: Add File.AttachmentURI for convenience 2021-02-24 01:59:33 -08:00
Maximilian von Lindern a969b11709
Gateway: Add graceful closing with CloseGracefully (#185)
* gateway: add the possibility of graceful closure

* wsutil: rename ConnGracefulCloser to GracefulCloser

* Gateway: rename Gateway.CloseSession to .CloseGracefully
2021-01-29 20:25:10 -08:00
diamondburned 5252b5af8d httputil: Fix Timeout causing premature cancelation 2021-01-24 22:45:56 -08:00
diamondburned de3049b730 httputil: Fixed JSON body not reusable 2021-01-13 15:22:45 -08:00
diamondburned c6d8c741e8 CI: Add perseverance test for Gateway 2020-12-31 23:48:29 -08:00
diamondburned f1f052180b Heart: Improve thread-safety and pace responsiveness
This commit consists of these smaller commits:

    Gateway: SessionID to be a method for thread safety

	This commit breaks the SessionID field of the Gateway struct to
	be thread-safe by wrapping its access with a read-write mutex.
	As this is a bug fix, it is reasonable of a breaking change

    Heart: Allow later binding of event channel

    Voice: Use the new Heart API

    Heart: Fixed data races

    Heart: Allow changing pace, thread-safe Heartbeat
2020-12-31 01:32:45 -08:00
diamondburned 808dfb28bb httputil: Fixed Multipart writer not closing 2020-12-16 14:08:31 -08:00
diamondburned 525d0bb3f6 API: Move ExecuteWebhookData, add package sendpart for uploads
This commit moved ExecuteWebhookData from package api to package webhook
inside package api. This change required splitting the multipart
abstractions away from package api, so they are now inside package
sendpart in utils.

This commit will break code that uploads anything, as the type name is
now sendpart.File from api.SendMessageFile. The behavior should be the
same as before.
2020-12-16 13:11:11 -08:00
diamondburned d65807ce15 API: Potential rate limit fix for reactions 2020-12-11 17:58:52 -08:00
diamondburned 5a76b21ecf wsutil: Fixed irregular close 1000 error 2020-11-30 21:49:55 -08:00
Maximilian von Lindern 0a8b24339b
API: Added timeout if deadline is after rate limit (#173)
* Rate: don't sleep if sleep exceeds context deadline

* Httputil: add Client.Timeout

* Bot: set default API timeout to 5 minutes

* Rate: reduce calls to time.Now in Acquire

* API: Optimize to use deadline instead of recalculating

Co-authored-by: diamondburned <datutbrus@gmail.com>
2020-11-25 12:08:42 -08:00
mavolin b9d7ba4476 Option: fix nullable types getting serialized to nil on JSON null 2020-11-22 09:33:33 -08:00
diamondburned 1aaa2cbfe2 httputil: Removed debug logs 2020-11-14 15:36:18 -08:00
diamondburned 6cbe95d2b3 State: Fixed erroneous context setting and races in Ready 2020-11-14 15:30:18 -08:00
diamondburned f6e270ae9c json: Fixed a race condition with erroneous JSON streams 2020-11-14 14:18:50 -08:00
diamondburned a3aa490024 wsutil: Reset SendLimiter after Dial 2020-11-01 10:12:35 -08:00
diamondburned bd1696ef65 wsutil: Added super verbose logs 2020-11-01 10:12:31 -08:00
diamondburned a46d3c2c8d wsutil: Added possibly missing Reset cases and more debug logs 2020-10-31 15:54:51 -07:00
diamondburned 63310fdc95 wsutil: Added graceful close checking 2020-10-30 13:54:35 -07:00
diamondburned 16c1658163 {,Voice}Gateway: Refactored Closing
This commit refactors both wsutil, the normal Gateway and the Voice
Gateway to have better closing behavior, which should assume less and
cover edge cases completely.
2020-10-30 11:02:37 -07:00
diamondburned 8d21c5f43f Merge wsutil bug fixes and changes onto v2 2020-10-29 11:25:09 -07:00
diamondburned 7668fe940c wsutil: Websocket wrapper thread safety for simpler Conn impl
This commit removes the thread safety requirement that Conn
implementations must satisfy. It moves the mutex guards as well as the
multiple close wrapper over to the Websocket wrapper instead.
2020-10-29 11:24:45 -07:00
diamondburned 9b4b707070 Handler: Use a free list over a linked list 2020-10-28 23:55:39 -07:00
diamondburned ef48d686cd Handler: Changed to a linked list instead of a slice-backed map
This change should slightly improve the performance of the handler
container.

A rough benchmark was written and tested; the source code is at
https://gist.github.com/diamondburned/c369d13efda5c702a0e59874deee64bd.
2020-10-28 22:37:38 -07:00
diamondburned 33e7abd4db Merge wsutil fix from v1 into v2 2020-10-28 19:03:10 -07:00
diamondburned 160a4e6606 wsutil: Fixed data races involving getters 2020-10-28 19:00:59 -07:00
diamondburned 75df94d9f4 *: Migrated Go Modules to v2 2020-10-28 15:39:59 -07:00
diamondburned 16a408bf30 wsutil: Refactored and decoupled structures for better thread safety 2020-10-28 10:19:22 -07:00
diamondburned 6c332ac145 {Voice,}Gateway: Fixed various race conditions
This commit fixes race conditions in both package voice, package
voicegateway and package gateway.

Originally, several race conditions exist when both the user's and the
pacemaker's goroutines both want to do several things to the websocket
connection. For example, the user's goroutine could be writing, and the
pacemaker's goroutine could trigger a reconnection. This is racey.

This issue is partially fixed by removing the pacer loop from package
heart and combining the ticker into the event (pacemaker) loop itself.

Technically, a race condition could still be triggered with care, but
the API itself never guaranteed any of those. As events are handled
using an internal loop into a channel, a race condition will not be
triggered just by handling events and writing to the websocket.
2020-10-22 10:47:27 -07:00
diamondburned 91ee92e9d5 Gateway: Fixed a race condition on ReconnectOP 2020-10-21 22:42:16 -07:00
diamondburned 6b4e26e839 wsutil: Improved internal code 2020-08-20 14:15:52 -07:00
diamondburned de61fd912d wsutil: Made PacemakerLoop valid as zero-value 2020-08-19 21:30:57 -07:00
diamondburned 94cca0adca httputil: Fixed unlock of unlocked mutex bug 2020-08-04 14:09:43 -07:00
Maximilian von Lindern 1585797b52 *: Linting and typo fixes (#134)
* Linting and typo fixes

* Linting and typo fixes

* revert comma fix
2020-07-29 16:58:33 -07:00
Maximilian von Lindern 32789bb6e2 *: Separate utils and internal (#129)
* Utils: move package utils/heart to internal/heart

* Utils: move package utils/moreatomic to internal/moreatomic

* Utils: move package utils/zlib to internal/zlib
2020-07-29 16:58:33 -07:00
mavolin ba4b224168 handler: move package from /handler to /utils/handler 2020-07-29 16:58:33 -07:00
Tadeo Kondrak d290b0d01c *: Add typed Snowflake IDs (#122)
This PR closes #120.
2020-07-29 16:58:33 -07:00
diamondburned 5b37b2ab0d Gateway: Allow for longer timeouts 2020-07-14 18:47:52 -07:00
diamondburned c1885067d7 Gateway: Allow for more lenient gateway bursts 2020-07-14 18:47:15 -07:00
diamondburned f33b4ff7d8 wsutil: API changed to support contexts 2020-07-11 12:49:28 -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 a76c9031c1 API: fix #91 2020-05-22 10:52:30 -07:00
mavolin 41ce1f389e
make all error messages lowercase 2020-05-16 23:14:49 +02:00
diamondburned (Forefront) ae793848aa Utils: Exposed NullableTData structs 2020-05-12 17:09:43 -07:00
Maximilian von Lindern ae14c8fb73
Merge branch 'master' into 44-data-structs 2020-05-12 03:57:35 +02:00
mavolin 04a80d33e8
API: add docs, use option types 2020-05-12 03:44:13 +02:00