motiv-labs / janus

An API Gateway written in Go
https://hellofresh.gitbooks.io/janus
MIT License
2.8k stars 320 forks source link

Api is not reload when defenition is updated #257

Closed chendanshuang closed 6 years ago

chendanshuang commented 6 years ago

[Short description of problem here]

Reproduction Steps:

  1. [First Step]
  2. [Second Step]
  3. [Other Steps...]

Expected behavior:

[Describe expected behavior here]

Observed behavior:

[Describe observed behavior here]

Janus version: [Enter Atom version here] OS and version: [Enter OS name and version here]

chendanshuang commented 6 years ago

When I update a defenition by sending a put request. But the proxing does't use the new defenition, still use old defenition before. I reading the coad, in the PutBy handler, a notify of NoticeAPIUpdated will be sended, but nothing is handled when RequireReload is true.

Is that related codes is not opened now?

chendanshuang commented 6 years ago

Mentioned above, is in the case of database_dsn is file based, hot reload api defenition is not worked.

chendanshuang commented 6 years ago

And I change to use mongodb to store my api definition, hot reload api defenition is worked when api is updated.

I think it should behave the same no matter what database backend is confiugred.

italolelis commented 6 years ago

Hi @shuangstar,

The reason why it doesn't behave in the same way is that when you use a file-based configuration you can't expect the reload to work since we don't save any information. Think about it as Nginx, when you want to change a configuration you do it by editing the file and reload nginx, Janus works on the same way when you use a file-based configuration. If you use mongodb, you can use the API to save your changes and then we hot reload the configurations.

Maybe what we should do is to block the usage of the write API if you use file-based configurations, this way is less confusing.

I hope this helps to understand the issue.

chendanshuang commented 6 years ago

ok. Thx!

italolelis commented 6 years ago

I'm closing this issue since I think it's resolved. Feel free to reopen it if you still have problems