Raki
Reading MSDN document what does this mean while reading local function
One of the useful features of local functions is that they can allow exceptions to surface immediately. For iterator methods, exceptions are surfaced only when the returned sequence is enumerated, and not when the iterator is retrieved. For async methods, any exceptions thrown in an async method are observed when the returned task is awaited.I can understand with async method so while returning async only we will come to know about exceptions. Just for understanding so
For iterator methods, exceptions are surfaced only when the returned sequence is enumerated,
So this means when we enumerate like the collection is read like using for loop. But what this means and not when the iterator is retrieved
3 replies
Can anyone explain Bulkhead policy in polly
Can anyone explain Bulkhead policy in polly
I want to send API calls to an external API that only allows 10 calls per second. Therefore, I need my program to be limited to making only 10 HTTP calls per second. Additionally, if I encounter a 429 error (too many requests), I want to retry that call. I learned about the Bulkhead pattern from this article: https://medium.com/@ynskrn54/using-polly-and-the-bulkhead-pattern-in-net-f4a9639e2fcd, which helps in preventing overwhelming the external API.
I have written some code based on this pattern. My understanding is that this code will manage 10 calls at a time in a queue. For instance, if I have 30 HTTP calls to make, they will be queued and processed at a rate of 10 calls per second.
Is the below code serve my purpose
4 replies
How to slow down my api call to a external service using polly
How to reduce or slow down my api to call external system. I want to call contentful cms but they have limited 10 calls per second. Now when there is a large number of changes. I believe it exceeded the limit and start to throw 429 rate limiting error. So I want to slow down my request to contentful so that only 10 calls are send to it per second. How to achieve it in .net polly.
7 replies
How does option work in .net core
I have the below class here the contentfulclient base has a class called ContentfulClientBase which has a property called as contentfuloption with some property. I want to assign the value to one of the property. I have my own contentfuloption class which has some of the properties of ContentfulClientBase class contentfuloption. I want to pass my model value to contentfulclientbase class. But I don't know how to achieve it. When I use
_options = options.Value;
I get an error states type to type conversion is not possible.
Basically I want my baseclass property should get my value which I provide.
public class ContentfulManagementService : ContentfulClientBase, IContentfulManagementService
{
private readonly ILogger<ContentfulManagementService> _logger;
private readonly Models.ContentfulOptions _contentfulOptions;
public ContentfulManagementService(
HttpClient httpClient,
ILogger<ContentfulManagementService> logger, IOptions<Models.ContentfulOptions> options)
{
_httpClient = httpClient;
_logger = logger;
_contentfulOptions = options.Value;
}
}
99 replies
Beginner question. what does this createhostbuilder do?
I'm learning .net core and I saw this code in program.cs. I can understand the main method calls this createhostbuilder which in turn sets some config value. But what I don't know is from where this configuration comes. where does this config.AddKeyPerfile do. Can anyone explain
4 replies
Please help, Hi I need to write unit test for the following methods
I have my code with 3 to 4 methods I need to write unit test for them Any ideas. As you can see all are method which only calls http methods. I already wrote few to check whether they call the correct entry in xunit similar to below. Reaching to the community for your code review comments for the fiddler code and possibility of any unit testing beyond the one which I have written below.
https://paste.mod.gg/wvyxvurvrzuh/0
1 replies
why are thread.sleep, synchronous semaphore waits and other blocking calls harmful in async methods?
above is asked in a interview. what should be the answer. I replied that it will make the async operation useless since async will wait untill the process is executed in the mean time the thread will work on the next one
4 replies
❔ How to read configuration based on environment
I have a stored my connection string as configuration in web.config. Now I have stored the same connection string as application setting variable in app service. So now how to make my application to read from web.config while in dev environment and from app service which its deployed.
Existing code to get the connectionstring:
2 replies
❔ How to get azure cache for Redis connection string stored in app service as a appsetting variable
I have created a azure redis for cache and stored the connection string as application setting variable in app service using terraform. Now I want my code to access the connection string. In the existing application we explictly mentioned the connection string in web.config. So now I needed to get the azure appsetting variable via code.
Any link or reference is appreciated
4 replies
✅ How to check whether a given list is present in the List of list
I have a List<List<int>> candidates and before adding into it want to check whether a list is already present. The condition is true all the time. How to implement the check condition for each addition
8 replies
❔ How bit wise shift operation work
I started learning bit wise operation.
So i have a uint = 0101 bit which is int 5. Which is in loop to see how it works
Consider n =0101
1st iteration
var test = (n >> 0) // The value is 101
2nd iteration
var test = (n >> 1) // The value of test is 50
How this Happens what i assumed is 0101 on 2nd iteration will become as 1010 so it will be 9. But how it becomes 50.
10 replies