Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config param "ActivateEventChannels" #78

Closed
andersfylling opened this issue Oct 27, 2018 · 0 comments
Closed

Add config param "ActivateEventChannels" #78

andersfylling opened this issue Oct 27, 2018 · 0 comments
Labels
Projects
Milestone

Comments

@andersfylling
Copy link
Owner

andersfylling commented Oct 27, 2018

The current state of using channels for events is.. bad. The channels are not buffered and emptied once full, but rather a func called alwaysListenToChans is listening to all channels in a for loop. Which ofcourse causes loss of information.

func (d *Dispatch) alwaysListenToChans() {
go func() {
stop := false
for {
select {
case <-d.allChan:
case <-d.channelCreateChan:
case <-d.channelDeleteChan:
case <-d.channelPinsUpdateChan:
case <-d.channelUpdateChan:
case <-d.guildBanAddChan:
case <-d.guildBanRemoveChan:
case <-d.guildCreateChan:
case <-d.guildDeleteChan:
case <-d.guildEmojisUpdateChan:
case <-d.guildIntegrationsUpdateChan:
case <-d.guildMemberAddChan:
case <-d.guildMemberRemoveChan:
case <-d.guildMemberUpdateChan:
case <-d.guildMembersChunkChan:
case <-d.guildRoleCreateChan:
case <-d.guildRoleDeleteChan:
case <-d.guildRoleUpdateChan:
case <-d.guildUpdateChan:
case <-d.messageCreateChan:
case <-d.messageDeleteChan:
case <-d.messageDeleteBulkChan:
case <-d.messageReactionAddChan:
case <-d.messageReactionRemoveChan:
case <-d.messageReactionRemoveAllChan:
case <-d.messageUpdateChan:
case <-d.presenceUpdateChan:
case <-d.presencesReplaceChan:
case <-d.readyChan:
case <-d.resumedChan:
case <-d.typingStartChan:
case <-d.userUpdateChan:
case <-d.voiceServerUpdateChan:
case <-d.voiceStateUpdateChan:
case <-d.webhooksUpdateChan:
case <-d.shutdown:
stop = true
}
if stop {
break
}
}
}()
}

Dispatching to channels should be conditional, as most won't use them. Such that for those whom utilize handlers only, should not be affected by the extra resource usage that Disgord would require to manage the event channels. Regardless of how little of an performance impact that is.

Channels will still use the fan out pattern, but will require a form of scheduler to empty the channels before they are full to avoid deadlocks. New information/events must also not be deleted when the channels are emptied.

The Disgord users must understand that the event channels should not be used as a queue and any incoming events must be handled instantly. If the user desires a queue for events they must implement their own solution and populate it using Disgord. Not using the events channels within Disgord as a queue, since information will be lost.

@andersfylling andersfylling added this to the v0.8.0 milestone Oct 27, 2018
@andersfylling andersfylling added this to Low priority in Disgord v1 via automation Oct 27, 2018
@andersfylling andersfylling moved this from Low priority to High priority in Disgord v1 Oct 30, 2018
@andersfylling andersfylling changed the title Add config param "UsingEventChannels" Add config param "ActivateEventChannels" Oct 30, 2018
Disgord v1 automation moved this from High priority to Closed Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Disgord v1
  
Closed
Development

No branches or pull requests

1 participant