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

Getting input from HTTP(s) requests #43

Open
ndgnuh opened this issue Jun 28, 2020 · 3 comments
Open

Getting input from HTTP(s) requests #43

ndgnuh opened this issue Jun 28, 2020 · 3 comments

Comments

@ndgnuh
Copy link

ndgnuh commented Jun 28, 2020

This is the kind of use case that:

  • You have some kind of worker that send the data from time to time
  • Your dashboard listen to the worker, receive those data, process then display it

I can use update_output to update the output when the data are received, but how can I receive that kind of input though?

@angusmoore
Copy link
Owner

I haven't tested this particular use case, so there may be some complexities I'm not aware of. But off the top of my head, this use case is no different whether you're using Matte or not (other than the update_output of course). All you'll need to do is create a function in the server module to query the data source repeatedly (e.g. via HTTPs request), with some sleep in between each request so you aren't flooding the server, in an infinite loop (or a loop with some controllable shutdown condition if you like). Then just start that function as an async task (i.e. using julia @async macro) so that it is non-blocking for anything else the server needs to do.

I haven't tested this particular use case, but I think something along those lines should work. Hope that helps, let me know how you go.

@ndgnuh
Copy link
Author

ndgnuh commented Jun 29, 2020

Thanks, I'll try that out to see if that works. Polling sounds a bit unappealing, but that's just my feeling though. Maybe I'll open another server to listen to incoming data and find a way to make the two servers communicate.

@angusmoore
Copy link
Owner

Yes, fair. I think you could equally set up a lightweight server inside the Matte server module (e.g. using HTTP.jl or stdlib Sockets) and have that listener handle incoming data in the same way. Provided that listener is running in @async, I think it should be ok. But it's not something I've tested, so there may be some complication I'm missing.

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

2 participants