Commit graph

125 commits

Author SHA1 Message Date
jonas747
56b19073d3 Ratelimits (#273)
* Added ratelimiter

Handles the new ratelimit headers
 - X-RateLimit-Remaining
 - X-RateLimit-Reset
 - X-RateLimit-Global

* Pad only reset time with a second

* Moved ratelimiter out of internal package

* Change for loop, move global ratelimit check inside sleep check

* Moved ratelimiter locking to getBucket

* Added global bucket

* Changed how bucket id's are done

Now each request function will need to specify the bucket id if the
endpoint contains minor variables

* Allow empty bucketID in request

* Remove some uneeded Endpoint* function calls

* Added test for global ratelimits

* Fixed a silly little mistake causing incorrect ratelimits

* Update test comments, Fixed treating a endpoint as 2 in ratelimiting

* Use date header from discord instead of relying on sys time sync

* Update all REST functions to use RequestWithBucketID

* Embed mutex into bucket

* Added webhook and reaction buckets
2016-11-04 08:07:22 -07:00
Chris Rhodes
2e2e02fc11 Support a very light state in all cases to support b1nzy's upcoming PR (#260)
Support a very light state in all cases to support b1nzy's upcoming PR
2016-09-27 22:09:44 -07:00
Chris Rhodes
8bd3f75441 Merge pull request #227 from jonas747/retry
Retry on 502's
2016-09-27 21:19:25 -07:00
jonas747
ebb910f3ac Set default MaxRestRetries to 3 2016-09-27 18:25:40 +02:00
Bruce Marriner
43778dc54b Bump version to 0.14.0-dev 2016-07-19 07:44:38 -05:00
Bruce Marriner
11fa9dc906 Bump Version to 0.13.0 2016-07-18 17:12:48 -05:00
Bruce Marriner
9dc51d1c49 Only Shard when ShardCount > 1
Also cleaned up identify sending so there's now a function that handles
it instead of duplicate code.  Renamed handshake* structs to identify*
structs to make naming match up.
2016-06-14 13:45:38 -05:00
andrei
835a23a89d Implement guild sharding 2016-06-13 15:34:40 -07:00
Bruce Marriner
7ed2a289bc Fix possible mutex deadlock in handle()
Also added some logging.
2016-05-28 13:51:17 -05:00
Bruce Marriner
a9da8a5daf Cleanup, Logging, Finished Resumed code. 2016-04-30 21:40:13 -05:00
Bruce Marriner
f6de2b2c98 gateway, voice, & logging improvements
We now store teh sessionID of the gateway connection for later use. We
are now caching the gateway url and will use it until unable to connect
to that gateway.  We're not longer smashing the VoiceConnections map
during reconnects which was causing Voice problems. Slight change to
log output format.
2016-04-28 21:15:32 -05:00
Bruce Marriner
33f2fa8d81 Bump version to v0.13.0-alpha 2016-04-12 12:35:34 -05:00
Bruce Marriner
12b010078c Bump version to v0.12.0 2016-04-12 12:28:19 -05:00
Bruce Marriner
1a672823a2 Lint and Cleanup 2016-04-11 18:54:19 -05:00
Chris Rhodes
45e01b20c9 Fix ordering of the OnReady event and Session being updated. 2016-04-01 18:06:20 -07:00
Bruce Marriner
a40bf8952c Removed onEvent handler
With the recent change to the OnEvent event now always executing
insted of only on error we don't want this printing out every
single event.  A different way to handle unknown events will be
added in the wsapi.go code.
2016-03-21 17:54:04 -05:00
Bruce Marriner
cd065fa61a Revert "Removed onEvent handler"
This reverts commit 974ed749e1.

Deleted the wrong function...
2016-03-21 17:53:15 -05:00
Bruce Marriner
974ed749e1 Removed onEvent handler
With the recent change to the OnEvent event now always executing
insted of only on error we don't want this printing out every
single event.  A different way to handle unknown events will be
added in the wsapi.go code.
2016-03-21 17:47:22 -05:00
Chris Rhodes
584b06aae5 Support VoiceSpeakingUpdates on VoiceConnection. 2016-03-18 10:50:25 -07:00
Bruce Marriner
44d4667463 Bump to v0.12.0-alpha 2016-02-20 20:59:40 -06:00
Bruce Marriner
cadf36c775 Bump to v0.11.0 2016-02-20 20:53:56 -06:00
Chris Rhodes
457b03f66e Fix deadlock because I'm dumb. 2016-02-19 23:00:41 -08:00
Chris Rhodes
c291988335 Bring back the Lock as it's technically correct. 2016-02-19 22:32:15 -08:00
Chris Rhodes
79247272ff Handler updates, no backwards incompatible API changes.
AddHandler now returns a func that can remove the handler.
The handlers map is now guarded by its own mutex.
Moved eventMap to events.go for readability.
Improved documentation.
2016-02-19 22:28:21 -08:00
Chris Rhodes
32f8c03270 Fix a Lock instead of RLock in initialize. 2016-02-19 11:25:46 -08:00
Chris Rhodes
d22b7ffc90 Clean up mutexes around s.handlers so they exist only in discord.go 2016-02-17 23:17:31 -08:00
Bruce Marriner
aebfb09719 Baby Linting. 2016-02-15 21:50:41 -06:00
Chris Rhodes
b083ce00c7 Un-expose handlers. Clean up Session struct. 2016-02-14 21:58:29 -08:00
Chris Rhodes
88335b6f54 Small performance improvement. Added tests. 2016-02-14 19:01:45 -08:00
Chris Rhodes
6fa99712ef Finish converting large switch statement into a map of functions. 2016-02-14 18:48:37 -08:00
Chris Rhodes
8ffaa85b0b Thread safety and more events. 2016-02-14 13:41:56 -08:00
Chris Rhodes
fb6ae92555 Add basic support for mapped event handlers. 2016-02-14 13:17:20 -08:00
Bruce Marriner
f917d83f6e Linting. 2016-01-27 23:39:56 -06:00
Bruce Marriner
9a63e50e22 Bump dev to v0.11.0-alpha 2016-01-27 13:31:14 -06:00
Bruce Marriner
fd42d568ec Bump version to v0.10.0 2016-01-27 13:27:21 -06:00
Bruce Marriner
94b6199051 ShouldReconnectOnError and Compress are defaulted to true with New() 2016-01-24 13:21:32 -06:00
Chris Rhodes
bf5ca4d690 Fix comment. 2016-01-21 10:59:30 -08:00
Chris Rhodes
8b39278c3e Get rid of Listen. 2016-01-21 10:58:13 -08:00
Chris Rhodes
c4869d7a43 Remove handshake. 2016-01-21 09:19:20 -08:00
Chris Rhodes
cd55a59ff9 Refactor open/close logic. Support OnConnect and OnDisconnect. 2016-01-20 22:47:34 -08:00
Chris Rhodes
1d9f97e283 Update New to allow an auth token to be specified. 2016-01-17 14:17:51 -08:00
Bruce Marriner
daa230a3c1 Bump dev version to 0.10.0-alpha 2016-01-12 08:31:00 -06:00
Bruce Marriner
e1bfc285a0 Bump version to 0.9.0 2016-01-12 08:29:44 -06:00
Bruce Marriner
2469147d8a Even better checking that we don't close nil/closed chans. 2016-01-11 14:33:01 -06:00
Bruce Marriner
61b3b8122c Only close chans if they are open, closes #80 2016-01-11 13:23:11 -06:00
Bruce Marriner
b5e45827fd Better error checking for New() and Gateway() funcs, closes #75 2016-01-10 19:01:34 -06:00
Bruce Marriner
301fb980d3 Updated copyright year, cleaned up some comments. 2016-01-07 13:50:44 -06:00
Bruce Marriner
d737b91b77 Bump version to v0.9.0-alpha 2016-01-06 16:43:06 -06:00
Bruce Marriner
ad7b7603c6 Bump version for v0.8.0 2016-01-06 16:36:34 -06:00
Bruce Marriner
1ae278b8c0 Modify session close function to do a better job 2016-01-04 13:13:10 -06:00
Chris Rhodes
9ba6d5b7c1 Make state tracking optional. 2016-01-02 12:01:03 -08:00
Chris Rhodes
4e23e5fc35 Implement state tracking.
Currently maintains a list of Guilds (Members/Channels) and PrivateChannels.
2016-01-01 22:47:19 -08:00
Bruce Marriner
4e90b453b6 Bump develop branch to version 0.8.0-alpha 2015-12-29 13:48:18 -06:00
Bruce Marriner
31e27aaffb Bump version to 0.7.0 2015-12-29 13:45:28 -06:00
Bruce Marriner
ff03e10888 Bump version for 0.7.0-alpha for development 2015-12-21 11:52:54 -06:00
Bruce Marriner
cc6280cee3 Bump version to 0.6.0 2015-12-21 11:48:11 -06:00
Bruce Marriner
0a5055904c Up version to 0.6.0-alpha 2015-12-21 09:48:07 -06:00
Bruce Marriner
0fbfc66554 Comments, example posible future main data struct 2015-12-20 00:12:57 -06:00
Bruce Marriner
40a7e717f5 Added VERSION constant 2015-12-17 08:23:48 -06:00
Bruce Marriner
1d06c4a3b8 Added helper func New() which greatly simplifies creating a new Discord session. 2015-12-07 13:54:06 -06:00
Bruce Marriner
552abf8818 Reworded package comment 2015-11-23 10:17:10 -06:00
Bruce Marriner
35e3966b91 Reworded top comment 2015-11-23 10:16:23 -06:00
Bruce Marriner
10044d50e8 Initial add of discord.go to be used for higher level functions 2015-11-23 09:45:07 -06:00
Bruce Marriner
0a76b91f00 discord.go file has no purpose right now. 2015-11-22 14:37:50 -06:00
Bruce Marriner
f4445fb782 Commented out file, as it's not being used now. 2015-11-12 12:21:10 -06:00
Bruce Marriner
a5d3e9378e Made session in Discord strut a pointer. Probably will change that again :) 2015-11-12 09:59:02 -06:00
Bruce Marriner
0840d1003d Removed endpoint variables and moved to restapi.go 2015-11-09 15:09:56 -06:00
Bruce Marriner
2c3ca777f9 Clean up, notes 2015-11-09 14:22:36 -06:00
Bruce Marriner
fff4fa20e9 Clean up 2015-11-08 21:57:49 -06:00
Bruce Marriner
e6789fde74 Inital add of Websockets 2015-11-08 21:42:16 -06:00
Bruce Marriner
302f4976a9 Renamed RequestToken to Login 2015-11-03 08:51:21 -06:00
Bruce Marriner
66da5a3ae4 Created a client.go with low level access functions and started
working on "easy access" methods in each data structure that point
to the low level client.go functions.  Added channel.go, server.go
2015-11-03 08:35:58 -06:00
Bruce Marriner
a878ca687a Should have been a pointer, I think :) 2015-11-02 19:36:34 -06:00
Bruce Marriner
535c10752d Slightly improved comments 2015-11-02 19:31:31 -06:00
Bruce Marriner
c0f68b4bd5 Refactoring stuff, moved things around :) 2015-11-02 16:43:10 -06:00