-
Notifications
You must be signed in to change notification settings - Fork 37
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
chore(channels): use channels from channels package #272
chore(channels): use channels from channels package #272
Conversation
DEV-2125 Messaging make a channels package
Putting all channels in a single package will allow use to write v2 versions more easily, as well as decoupling the channel code from the server code, and reducing considerably the amount of code in the server package |
this.cache = await this.cachingService.newServerCache('cache_instance_by_conduit_id', { | ||
dispose: async (k, v) => { | ||
if (!this.destroyed) { | ||
await this.handleCacheDispose(k, v) | ||
} | ||
}, | ||
max: 50000, | ||
maxAge: ms('30min') | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to put back this logic of clearing channels after not being used for x amount of minutes. To be done in future PR.
private async onConduitDeleting(conduitId: uuid) { | ||
this.cache.del(conduitId, true) | ||
await this.instances.stop(conduitId) | ||
} | ||
|
||
private async onConduitUpdated(conduitId: uuid) { | ||
this.cache.del(conduitId, true) | ||
await this.instances.stop(conduitId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice here we were doing distributed invalidations on the cache. Now there is a dispatcher in the instance service that informs the other node when they need to stop their conduit
@@ -27,6 +27,7 @@ | |||
"dependencies": { | |||
"@botpress/messaging-base": "0.0.1", | |||
"@botpress/messaging-engine": "0.0.1", | |||
"@botpress/messaging-channels": "0.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider using '*' as the version since it references another package and we want to use it whatever version it is at
}) | ||
this.cache.set(conduitId, instance, channel.lazy && this.lazyLoadingEnabled ? undefined : Infinity) | ||
|
||
await this.emitter.emit(InstanceEvents.Setup, conduitId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make more sense IMHO if we were to send events with the same name as the function that triggers them! So in this case, shouldn't we use Start instead of setup? Or maybe we should rename the function to setup instead of start? What do you think?
private useWebhook() { | ||
// TODO: remove this dependency on server env vars | ||
return !yn(process.env.SPINNED) || yn(process.env.CLUSTER_ENABLED) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In future PR
* delete channel code * chore(channels): use channels from channels package (#272) * use telegram from channel package * use package twilio * use teams * use smooch * example change * config change * slack * messenger * vonage * integrate other channels * telegram + * fix tests * fix docker * initialize * stop when server closes * dispatch stop * webhookRouter * ChannelTemplate * prettier * fix
* feat(channels): conversation.started * fix * feat(channels): channels package * fix * config file * schwag * more schwag * twilio * twilio validation * smooch * change config * abstract * abstract telegram * abstract twilio * abstract app * fix * teams * fix * bring changes * bring changes * bring changes * add base renderers * refact streams * telegram all content types * abstract * twilio all content types * slack all content types * vonage all content types * messenger all content * teams all content * smooch all content * destroy * initialize * bring changes * chore(channels): delete channels (#271) * delete channel code * chore(channels): use channels from channels package (#272) * use telegram from channel package * use package twilio * use teams * use smooch * example change * config change * slack * messenger * vonage * integrate other channels * telegram + * fix tests * fix docker * initialize * stop when server closes * dispatch stop * webhookRouter * ChannelTemplate * prettier * fix * any -> void * remove || '*' in server * remove ChannelStreamRenderers * initialize messenger * messenger map scope * fix * put back twilio testing * vonage receive content types * restore index responses * fix * fix * logger * logger * printWebhook * kvs interface * fix
Imports channels from the @botpress/messaging-channels packages and uses them as replacement for the old channel code that was inside the server code.
Closes DEV-2125