ha-wechaty v0.4.16
HAWechaty
HAWechaty is a Load Balance for providing High Availability for Wechaty Chatbot by spreading requests across multiple WeChat individual accounts.
One two three, chatbots team up!
The Problem
Currently we have only one bot on WeChat, which means that if the bot was offline, then our service will be stopped.
The Solution
Use two (3 or even 4 will be better) WeChat bot at the same time, with the different wechaty-puppet providers (for example: padplus + windows).
So when an issue event has come, we can use a RR (round robin) or other very easy to implementing algorithm to make our service both load-balancable and high-available.
Usage
import {
HAWechaty,
} from 'ha-wechaty'
import {
WechatyOptions,
} from 'wechaty'
const hostieWechatyOptions: WechatyOptions = {
puppet: 'wechaty-puppet-hostie',
puppetOptions: {
token: 'hostie-token'
}
}
const padplusWechatyOptions: WechatyOptions = {
puppet: 'wechaty-puppet-padplus',
puppetOptions: {
token: 'padplus-token'
}
}
const haWechaty = new HAWechaty({
name: 'high-available-wechaty',
wechatyOptionsList: [
hostieWechathyOptions,
padplusWechatyOptions,
]
})
haWechaty.start()
Environment Variables
1 HA_WECHATY_PUPPET
The wechaty puppet list, seprated by a colon (:
).
Examples:
export HA_WECHATY_PUPPET=wechaty-puppet-hostie:wechaty-puppet-padplus
2 HA_WECHATY_PUPPET_${PROTOCOL}_TOKEN
The ${PROTOCOL}
could be the puppet name that the Wechaty supported.
For example:
Puppet Provider | ${PROTOCOL} | HAWECHATY_PUPPET${PROTOCOL}_TOKEN |
---|---|---|
wechaty-puppet-hostie | hostie | HA_WECHATY_PUPPET_HOSTIE_TOKEN |
wechaty-puppet-padplus | padplus | HA_WECHATY_PUPPET_PADPLUS_TOKEN |
wechaty-puppet-macpro | macpro | HA_WECHATY_PUPPET_MACPRO_TOKEN |
The token set to this environment variable will become the default value of puppetOptions.token
when instanciating Wechaty.
To specify more tokens for a specific puppet, use a colon (:
) to seprate them, for example:
export HA_WECHATY_PUPPET_HOSTIE_TOKEN=hostie_token_1:hostie_token_2
History
master
v0.0.1 (Apr 2020)
This module was originally design for the project OSSChat #58
- Publish the NPM module ha-wechaty
Links
- RxJS recipes: ‘forkJoin’ with the progress of completion for bulk network requests in Angular
- Handle multiple API requests in Angular using mergeMap and forkJoin to avoid nested subscriptions
- Googl Cloud - Truncated exponential backoff
- Power of RxJS when using exponential backoff
Author
Copyright & License
- Code & Docs © 2020-now Huan LI \zixia@zixia.net\
- Code released under the Apache-2.0 License
- Docs released under Creative Commons
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago