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

Runtime modifications to a published service #162

Open
fadedreamz opened this issue Nov 7, 2016 · 20 comments
Open

Runtime modifications to a published service #162

fadedreamz opened this issue Nov 7, 2016 · 20 comments
Assignees
Labels
Milestone

Comments

@fadedreamz
Copy link

Dynamic publishing of new URI resource after a service has been started

Current implementation does not allow to change the published service.

@ben-crowhurst
Copy link
Member

Hey, If you have any questions regarding the implementation don't hesitate to get in contact. We shall offer as much support as we can.

@ben-crowhurst
Copy link
Member

Linking original StackOverflow question for completeness.

@fadedreamz
Copy link
Author

If the service is running on a single threaded mode or a multi-threaded mode (lets say 4 workers); is it possible that the number of threads accessing the paths and the methods will exceed the number of allowed workers in service_impl?

@ben-crowhurst
Copy link
Member

ben-crowhurst commented Nov 8, 2016

Users can set any thread limit via void set_worker_limit( const unsigned int value );

@ben-crowhurst
Copy link
Member

ben-crowhurst commented Nov 8, 2016

The safest approach is to lock the resources via a std::mutex. This will block the service when engaged and should be held for the shortest possible duration.

@fadedreamz
Copy link
Author

Yes, I first I thought so, but this will have a very bad performance impact on a multi-threaded service. Even if there is no changes, one thread will be blocking another thread from reading the paths and methods. I am thinking to find some other good approach to minimize the impact.

@ben-crowhurst
Copy link
Member

Why not only lock the resources when writing? Anything that doesn't intend to write shall just have to check if its clear to move ahead, otherwise schedule itself for processing at a later date.

@fadedreamz
Copy link
Author

Yes, I was thinking the same, doing some sort of combination of reading_counter and lock to enable lock for readers when the writing is going on, otherwise just execute the code. But I will go according to your suggestion. Thanks

@ben-crowhurst
Copy link
Member

ben-crowhurst commented Nov 9, 2016

Have a look at Service::schedule( ); That will place the task back on the run-loop for later processing. Alternatively you could use Session::sleep_for but you'd have to guess how long to sleep for.

@fadedreamz
Copy link
Author

I tried to lock the resource before writing and reschedule the reading function, but Service::schedule() does not take any parameters. Although Session::sleep_for() should be able to do the required task. So, instead of going for guess work; I did implement the combination of reader_counter and lock in service_impl; wrote a sample example and tested it.
Here is the test result for make test
99% tests passed, 1 tests failed out of 109
Total Test time (real) = 16.63 sec
The following tests FAILED:
58 - runtime_service_modifications_acceptance_test_suite (Failed)

I have to do a smoke test with curl script.

@fadedreamz
Copy link
Author

Hi how can I perform pull request for code review?

@ben-crowhurst
Copy link
Member

Please review Creating a Pull Request.

@fadedreamz
Copy link
Author

#165

@ben-crowhurst
Copy link
Member

Just informing any other viewers. This feature won't be mainlined until after the 4.5 release.

@ben-crowhurst ben-crowhurst modified the milestone: 5.0 Dec 14, 2016
@ben-crowhurst ben-crowhurst modified the milestones: 5.0, 4.6 Apr 23, 2017
@mipac
Copy link

mipac commented Nov 1, 2017

hi all,
i'd like to use this feature
can someone explain how to apply this patch
or does someone know when it is planned for release

thank you very much

@fadedreamz
Copy link
Author

fadedreamz commented Nov 3, 2017 via email

@mipac
Copy link

mipac commented Nov 3, 2017

thanks for your answer

but i'm not sure to have a good git level :)
could you details a little more?

thank you and sorry for my poor git skills ;)

@fadedreamz
Copy link
Author

fadedreamz commented Nov 3, 2017 via email

@mipac
Copy link

mipac commented Nov 3, 2017 via email

@mipac
Copy link

mipac commented Aug 22, 2019

this feature could be push in the 5.0 To Do list

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

No branches or pull requests

3 participants