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

db 连接 dispatcher 的限定,防止错连、误连 #4

Open
kaven276 opened this issue Jan 6, 2016 · 0 comments
Open

db 连接 dispatcher 的限定,防止错连、误连 #4

kaven276 opened this issue Jan 6, 2016 · 0 comments

Comments

@kaven276
Copy link
Member

kaven276 commented Jan 6, 2016

global.startCfg = {
  listen_port : program.listen_port,
  client_config : program.client_config,
  keep_alive_interval : program.keep_alive_interval || 280,
  db : {
    name : program.db_name,
    domain : program.db_domain,
    unique : program.db_unique_name,
    inst : program.db_instance,
    role : program.db_role,
    cfg_id : program.db_cfg_id
  }
};
  var db = {
    name : headers['x-db_name'],
    domain : headers['x-db_domain'],
    unique : headers['x-db_unique_name'],
    con_name : headers['x-con_name'],
    role : headers['x-database_role'],
    inst : parseInt(headers['x-instance']),
    cfg_id : headers['x-cfg_id']
  };

  for (var n in db) {
    if (startCfg.db[n] && startCfg.db[n] !== db[n]) {
      // todo: add warning
      logLifeCycle('db[%s] not match %s(config) != %s(incoming)', n, startCfg.db[n], db[n]);
      logLifeCycle(db);
      logLifeCycle(startCfg.db);
      return false;
    }
  }
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

No branches or pull requests

1 participant