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

Use /events API #29

Open
trajano opened this issue Oct 21, 2023 · 0 comments
Open

Use /events API #29

trajano opened this issue Oct 21, 2023 · 0 comments

Comments

@trajano
Copy link

trajano commented Oct 21, 2023

You noted in the README

The interaction with docker API is a fairly rough implementation and is not very optimized. The server polls the API every 500 ms, publishing the response data to all open WebSockets if it changed since last time. There is probably a better way to look for changes in the Swarm that could be used in the future.

The way I think you can do this is with /events but from my experience, I suggest you use it as a trigger to pull changes asap rather than building from it.

That is to say the logic would be something like

  1. /events?since=0s monitor to start listening for an event record
  2. If event received or 2 seconds (as fallback) have passed pause the monitor
  3. fetch the data and update from whatever is needed
  4. restart the monitor

You can "reconsititute" some of the data using the events but I suggest you skip that notion first because some events may get dropped or the order may not be what you expect. (again based on experience writing this https://github.com/trajano/spring-cloud-demo/blob/rework/gateway/src/main/java/net/trajano/swarm/gateway/discovery/DockerEventWatcher.java)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants