Просмотр исходного кода

make publish method asynchronous

Yuki Takei 5 лет назад
Родитель
Сommit
971d9b850d

+ 1 - 1
src/server/service/config-manager.js

@@ -312,7 +312,7 @@ class ConfigManager {
 
   async publishUpdateMessage(updatedAt) {
     const message = JSON.stringify({ updatedAt });
-    this.configPubsub.publish(message);
+    return this.configPubsub.publish(message);
   }
 
   async handleUpdateMessage(message) {

+ 1 - 1
src/server/service/config-pubsub/base.js

@@ -12,7 +12,7 @@ class ConfigPubsubDelegator {
     throw new Error('implement this');
   }
 
-  publish() {
+  async publish() {
     throw new Error('implement this');
   }
 

+ 2 - 2
src/server/service/config-pubsub/nchan.js

@@ -53,7 +53,7 @@ class NchanDelegator extends ConfigPubsubDelegator {
   /**
    * @inheritdoc
    */
-  publish(message) {
+  async publish(message) {
     const pathname = this.channelId == null
       ? this.publishPath //                                 /pub
       : path.join(this.subscribePath, this.channelId); //   /pub/my-channel-id
@@ -62,7 +62,7 @@ class NchanDelegator extends ConfigPubsubDelegator {
 
     logger.debug('Publish message', message);
 
-    axios.post(publishUri.toString(), message);
+    return axios.post(publishUri.toString(), message);
   }
 
   /**