-
Notifications
You must be signed in to change notification settings - Fork 10
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
Question about usage #51
Comments
We currently use it in production - I haven't gotten feedback from other companies that are also using it, but would love to hear them reply about it here if they are! Definitely interested in continuing to contribute. In fact, I've been doing quite a bit of work on the next version (2.6.0) that addresses some of the things I didn't like about how I originally used #46 and #47 are the upcoming PRs. I don't have a timeline on them, but I anticipate they'll be released within the next couple months. I've sidelined them for just a bit while working on a couple other things, but plan to pick them up at the beginning of the new year. Happy to answer other questions you might have, and always receptive to feedback. |
I think the documentation and new interface doesn't really match. I'm looking forward to your PR, I'm planning to use it, but not if I'm forced to implement sync methods. |
True - still working through some things and then I'll get the docs updated.
There's no intent to force sync implementations (you'd just be able to extend I'm interested in hearing more on your thoughts there. My take is that (and this seems to be the community/expert consensus) converting between sync/async (especially async-up-to-sync) is generally ill-advised (since you lose a lot of the async advantages), which is the driving force for needing two separate implementations (i.e. the underlying behavior of the sync one will differ from the async). |
Yes don't get me wrong, the PR looks good, I meant the current implementation with ICommand and Invoke / InvokeAsync Edit: Sorry my fault, I need to use Command, not ICommand. Imagine we want to write a REST Service and secure it with mjolnir (great!). |
That's true with the current API (inheriting from I like the Question: how important is it for you that fallback behavior is provided by Mjolnir vs. just coding the fallbacks in your own code? I've been scoping them out of this rework, but am open to re-including them. My hope was that the introduction of Thanks for your feedback, this is super useful. |
Thought about it and made a little, easy POC... -- Command -- public class ServiceCallCommand<T> : Command<CommandResult<T>>
{
private readonly string _url;
public ServiceCallCommand(string url) : base("group", "isolationKey", TimeSpan.FromSeconds(30))
{
_url = url;
}
protected override async Task<CommandResult<T>> ExecuteAsync(CancellationToken cancellationToken)
{
HttpResponseMessage response = null;
CommandResult<T> cresult = new CommandResult<T>();
using (HttpClient client = new HttpClient())
{
try
{
response = await client.GetAsync(_url);
cresult.value = await response.Content.ReadAsAsync<T>();
}
catch (Exception ex)
{
cresult.exception = ex;
cresult.store.Add("statusCode", response?.StatusCode);
}
}
return cresult;
}
}
public class CommandResult<TResult>
{
public Dictionary<string, object> store = new Dictionary<string, object>();
public TResult value { get; set; }
public Exception exception { get; set; }
public bool IsSuccessful => exception == null;
} -- Repository -- public async Task<CommandResult<string>> Get(string url)
{
ServiceCallCommand<string> command = new ServiceCallCommand<string>(url);
return await command.InvokeAsync();
} -- Controller -- This is not a good solution. I want the exact error code the origin request caused. CommandResult<string> result = await _repository.Get(url);
if(result.IsSuccessful)
{
_logger.LogInformation("Returning " + result);
return Ok(result);
}
else
{
_logger.LogInformation("Returning " + result);
object statusCode = 0;
if (result.store.TryGetValue("statusCode", out statusCode))
{
return new HttpStatusCodeResult((int) statusCode);
}
else
{
throw result.exception;
}
} The drawback is of cause that I have CommandResult everywhere. |
I didn't quite follow this statement - it looks like an exception thrown from the repository would be one that probably wouldn't have an HTTP response status and rather be something like a connection error (that wouldn't have a status code anyway). You could also consider a more specific
Yeah, that was a sticking point for me as well with the new API, and my hope is that callers will "unwrap" at their point of execution to avoid it propagating out throughout their code. Not sure how well that applies in practice, though. |
That's a good point, thank you. I knew I took too much of "my" logic in the command. |
Hi @robhruska Thank you for answering my question. We are waiting for the new release. We have postponed the integration with Mjolnir until you release the new version so we can use the new mechanisms. Are you going to release it soon? |
Let me get back to you on that after this weekend, I'll see if I can tie a bow on that release. It's pretty close, just needs a couple more tasks finished and some testing. |
@Wesam18 I've pushed a prerelease version of 2.6.0 up to nuget.org. You can install it via the NuGet package manager dialog, or via the package manager console using It should be pretty stable. Unit tests pass, and some high-level soak tests also look good. However, I still have tests to run on our staging environments, and need to get it deployed to some of our services. Once I've proven it on some of our production systems I'll push the official 2.6.0 to NuGet. If you run into any problems, please file issues here on GitHub so I can get them into the official release. The Wiki has been updated with full 2.6.0 documentation. https://github.com/hudl/Mjolnir/wiki I'd appreciate any feedback or suggestions you have along the way! |
Thank you very much @robhruska |
@robhruska Any updates on releasing 2.6.0? |
I had to sideline it for a bit. We've still got some testing to do in-house in our production environment before I'm comfortable saying that everything's good to go for 2.6.0. Out of curiosity, have you tried the 2.6.0 RC? If so, I'd be interested in knowing if it's worked in any testing you've done to this point. I'll make it higher priority to get it shipped. Apologies for the delay. If all goes well with our testing, I can try and have it out within a few weeks. I haven't made any changes to the RC, so if testing and production deployment go well, that's the package that'll be released if you want to use it in the meantime. |
We've been using the RC build for a few weeks with only one command type set up. So far it seems to be great, except for bulkhead config events not firing (I made a separate issue about that #53). The new metrics that you created are a lot more useful then the old stats. |
As 2.6.0 has been released, I'm going to close this one out. Feel free to reopen (or open another issue) for additional discussion. |
We are thinking to use Mjolnir in our applicaiton and we would like to know about how many companies are using it now?. Is it porduciton ready code?. Are you willing to continue contributing to the project?
The text was updated successfully, but these errors were encountered: