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

chore(channels): use channels from channels package #272

Merged
merged 28 commits into from
Dec 9, 2021

Conversation

samuelmasse
Copy link
Contributor

@samuelmasse samuelmasse commented Dec 3, 2021

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

@linear
Copy link

linear bot commented Dec 3, 2021

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

Comment on lines -85 to -93
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')
})
Copy link
Contributor Author

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.

Comment on lines 48 to +53
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)
Copy link
Contributor Author

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",
Copy link
Contributor

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

packages/server/src/channels/api.ts Outdated Show resolved Hide resolved
packages/server/src/channels/service.ts Outdated Show resolved Hide resolved
})
this.cache.set(conduitId, instance, channel.lazy && this.lazyLoadingEnabled ? undefined : Infinity)

await this.emitter.emit(InstanceEvents.Setup, conduitId)
Copy link
Contributor

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?

packages/server/src/sync/schema.ts Outdated Show resolved Hide resolved
Comment on lines 79 to 82
private useWebhook() {
// TODO: remove this dependency on server env vars
return !yn(process.env.SPINNED) || yn(process.env.CLUSTER_ENABLED)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future PR

@samuelmasse samuelmasse marked this pull request as ready for review December 9, 2021 18:34
@samuelmasse samuelmasse merged commit 5e8d579 into sm-server-delete-channels Dec 9, 2021
@samuelmasse samuelmasse deleted the sm-server-use-channels branch December 9, 2021 18:34
samuelmasse added a commit that referenced this pull request Dec 9, 2021
* 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
samuelmasse added a commit that referenced this pull request Dec 10, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants