Example #1
0
pro.setProtos = function(type, path) {
  if(!fs.existsSync(path)) {
    return;
  }

  if(type === Constants.RESERVED.SERVER) {
    this.serverProtos = protobuf.parse(require(path));
  }

  if(type === Constants.RESERVED.CLIENT) {
    this.clientProtos = protobuf.parse(require(path));
  }

  //Set version to modify time
  var time = fs.statSync(path).mtime.getTime();
  if(this.version < time) {
    this.version = time;
  }

  //Watch file
  var watcher = fs.watch(path, this.onUpdate.bind(this, type, path));
  if (this.watchers[type]) {
    this.watchers[type].close();
  }
  this.watchers[type] = watcher;
};
Example #2
0
Component.prototype.setProtos = function(type, path) {
  if (!fs.existsSync(path)) {
    return;
  }

  if (type === Constants.RESERVED.SERVER) {
    this.serverProtos = protobuf.parse(require(path));
  }

  if (type === Constants.RESERVED.CLIENT) {
    this.clientProtos = protobuf.parse(require(path));
  }

  this.version = _calcVersion(this.clientProtos, this.serverProtos);

  //Watch file
  const watcher = fs.watch(path, this.onUpdate.bind(this, type, path));
  if (this.watchers[type]) {
    this.watchers[type].close();
  }
  this.watchers[type] = watcher;
};
Example #3
0
pro.setProtos = function(type, path) {
  if(!fs.existsSync(path)) {
    return;
  }

  if(type === Constants.RESERVED.SERVER) {
    this.serverProtos = protobuf.parse(require(path));
  }

  if(type === Constants.RESERVED.CLIENT) {
    this.clientProtos = protobuf.parse(require(path));
  }

  var protoStr = JSON.stringify(this.clientProtos) + JSON.stringify(this.serverProtos);
  this.version = crypto.createHash('md5').update(protoStr).digest('base64');

  //Watch file
  var watcher = fs.watch(path, this.onUpdate.bind(this, type, path));
  if (this.watchers[type]) {
    this.watchers[type].close();
  }
  this.watchers[type] = watcher;
};
Example #4
0
  fs.readFile(path, 'utf8' ,function(err, data) {
    try {
      var protos = protobuf.parse(JSON.parse(data));
      if(type === Constants.RESERVED.SERVER) {
        protobuf.setEncoderProtos(protos);
      } else {
        protobuf.setDecoderProtos(protos);
      }

      this.version = fs.statSync(path).mtime.getTime();
      logger.debug('change proto file , type : %j, path : %j, version : %j', type, path, this.version);
    } catch(e) {
      logger.warn("change proto file error! path : %j", path);
      logger.warn(e);
    }
  });
Example #5
0
 fs.readFile(path, 'utf8' ,function(err, data) {
   try {
     var protos = protobuf.parse(JSON.parse(data));
     if(type === Constants.RESERVED.SERVER) {
       self.serverProtos = protos;
       protobuf.setEncoderProtos(protos);
     } else {
       self.clientProtos = protos;
       protobuf.setDecoderProtos(protos);
     }
     var protoStr = JSON.stringify(self.clientProtos) + JSON.stringify(self.serverProtos);
     self.version = crypto.createHash('md5').update(protoStr).digest('base64');
     logger.info('change proto file , type : %j, path : %j, version : %j', type, path, self.version);
   } catch(e) {
     logger.warn("change proto file error! path : %j", path);
     logger.warn(e);
   }
 });
Example #6
0
  fs.readFile(path, 'utf8', (err, data) => {
    try {
      const protos = protobuf.parse(JSON.parse(data));
      if (type === Constants.RESERVED.SERVER) {
        protobuf.setEncoderProtos(protos);
        this.serverProtos = protos;
      } else {
        protobuf.setDecoderProtos(protos);
        this.clientProtos = protos;
      }
      this.version = _calcVersion(this.clientProtos, this.serverProtos);

      logger.info('change proto file, type: %j, path: %j, version: %j',
                  type, path, this.version);
    } catch (e) {
      logger.warn('change proto file error! path: %j', path);
      logger.warn(e);
    }
  });
Example #7
0
  },  
  "LogGroupList":
  {
      "message LogGroup":
      {
          "repeated Log logs": 1,
          "optional string category": 2,
          "optional string topic": 3,
          "optional string source": 4,
          "optional string MachineUUID":5
      },
      "repeated LogGroup logGroupList":1
  }
};

var protos = po_protobuf.parse(proto_json);



ALY.SLS = ALY.Service.defineService('sls', ['2015-06-01'], {
  /**
   * @api private
   */
  initialize: function initialize(options) {
    ALY.Service.prototype.initialize.call(this, options);
  },

  setupRequestListeners: function setupRequestListeners(request) {

    request.addListener('build', this.addContentType);
    request.addAsyncListener('build', this.buildContent);