Questions tagged [asynchronous-programming]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-4
votes
0answers
19 views

Question Regarding the blocking/non-blocking nature of external HTTP requests using SpringBoot andRestTemplate

I have a question regarding making external requests using RestTemplate. I have a micro-service written using Spring Boot that based on an incoming user request, will in turn execute a http request ...
1
vote
1answer
58 views

Handling background tasks that may not be relevant when they are completed

Imagine the following pattern: you have a window with information that needs to be updated asynchronously. You launch and detach a thread to handle fetching the information, but while the information ...
1
vote
1answer
38 views

How could I optimize an AJAX-based site by avoiding unnecessary/duplicate file-reads for each AJAX call?

I'm an IT guy (read: not a professional programmer) and have made an internal monitoring webtool which allows users to search for printers on our print servers. Based on the filtering criteria given, ...
0
votes
0answers
62 views

Domain driven design and asynchronous code (repository)

I am trying to write domain code and I am pretty happy with my architecture so far. Problem started at point when I needed to create different implementation of repository, that required asynchronous ...
0
votes
1answer
72 views

What is the relationship between reactive programming and stream processing engines?

When would I use reactive programming libraries like RX Java and Project Reactor compared to stream processing engines such as Storm and Flink? I am aware that these concepts might not be directly ...
0
votes
1answer
101 views

How to approach a large number of multiple, parallel HttpClient requests?

I have a website which offers pages in the format of https://www.example.com/X where X is a sequential, unique number increasing by one every time a page is created by the users and never reused even ...
0
votes
2answers
112 views

What is the best practice for incorporating asynchronous code in this case?

Context: I'm building a popup widget. The html and css files are stored in S3. I need to get those files asynchronously and then continue with the rest of the logic. In the code below, I'm getting ...
3
votes
1answer
112 views

Is this a good design for wrapping asynchronous API calls into a RESTful interface?

I'm working with an API that has many asynchronous calls and handlers. I'd like to extend these with a RESTful interface and endpoints in spring. I'm imagining the usual Controller and Service layers, ...
1
vote
1answer
96 views

Implementing both Sync and Async clients with DRY

I'm developing a client library. I'd like to provide both Sync and Async interfaces to endpoints on a server. They would be rather easy to implement as completely separate entities, but I would like ...
-1
votes
2answers
76 views

How to GET multiple values from a database while keeping the request asynchronous?

This is a very small-scale project that I am coding myself, so I am able to build all of the resources however I like. I've done research on this site for help on this issue and can't find anything ...
5
votes
2answers
406 views

Is it good approach to await async tasks in object destructor?

I'm currently working on class with some async tasks under the hood. In fact I need to delegate few tasks to asynchronous execution and be sure that all of them are finished before class was destroyed,...
2
votes
2answers
55 views

Design tips for waiting for a user input while working on another thread

I am working on an application with multiple threads (using Qt, C++). One of this threads is designed to execute a batch of operations like reading/writing from/to files as well as creating new ones. ...
1
vote
0answers
29 views

Using TPL to manage hundreds of contexts

Overview of application: A chat bot that connects via IRC, using TPL. As messages come from the socket (from .ReadAsync()), they are ultimately parsed and passed to a handler within the bot itself (...
2
votes
2answers
128 views

Name of locking approach

I've seen this approach several times, both in async and multithreaded code. A counter is used to track asynchronous behavior or thread behavior - whenever a new action is started, the counter is ...
3
votes
3answers
753 views

Why is it necessary for every new api to be async?

I'm expressing my frustration here somewhat, but why do many new libraries only have asynchronous APIs? For example I'm creating a small utility to fetch a web page and parse some data from it. ...
0
votes
1answer
137 views

I'm writing an application that needs to log error/ exception messages but should still continue execution if it not a fatal error

I'm writing an application that needs to log error/ exception messages but should still continue execution if the error is not a fatal error. I was thinking of making a method that returns a Task but ...
0
votes
1answer
179 views

Heroku request timeout vs Nodejs architecture

At this link (https://blog.heroku.com/timeout-quickly#how-webservers-work), I read: All webservers will work in a similar way. Any new request will go to a queue, and the server will process ...
0
votes
1answer
82 views

Should repositories always return Rx Single or Observable?

Let' assume we have an IFiltersRepository repository that provides data about a list of "filters" that are used on the search screen of an app (filter by color, by price etc). The repository has the ...
1
vote
2answers
86 views

Acceptable to use synchronous call to another microservice for time-sensitve state change?

Say there are two microservices (example is simplified) PickupRequestService: lists pick-up requests of passengers DriverService: drivers use to accept pickup requests On a completely decoupled ...
7
votes
1answer
2k views

Is the C# async/Task construct equivalent to Java's Executor/Future?

I'm a long time Java developer, but with so little traffic on SE, I don't limit my viewing to any single tags. I've noticed that C# questions with async/await come up a lot, and as far as I've read it'...
0
votes
2answers
92 views

Turn an asynchronous delegate pattern into a blocking method

I have to use a built-in API that works like this class MyAPIWrapper { func callAPI() { apiObj.delegate = self apiObj.doWork() // returns immediately, eventually calls self.delegate....
0
votes
1answer
173 views

Which message pattern should I use?

I'd like to develop a microservice architecture application that sends text messages from one communication provider to another and I'm just considering changing architecture would be best suited to ...
29
votes
13answers
11k views

Why don't programming languages automatically manage the synchronous/asynchronous problem?

I have not found many resources about this: I was wondering if it's possible/a good idea to be able to write asynchronous code in a synchronous way. For example, here is some JavaScript code which ...
-4
votes
2answers
82 views

Should I use async for networking application/library [closed]

I decided to make an application, networking application, don't know what it has to do yet but mainly it should be a cross-client kind of like framework networking application/library. Since ...
-1
votes
1answer
305 views

Querying in event driven microservices

I am trying to get my head around "event driven" microservices. I understood, there are several techniques and patterns, like event notification, event sourcing, CQRS, etc that can help us to achive ...
1
vote
1answer
178 views

Refactor asynchronous code in C#

I got the following code snippet: public Task DistributeAsync(BankAccount account, decimal amount) { lock (account) { return repository.AddLoanAsync(account, amount).ContinueWith(task ...
2
votes
2answers
643 views

Is it okay for async function to update a common object

I have a couple of functions, each function verifies a set of rules and updates a common object. The common object is just a container that holds a list of rules that passed or failed. I would like to ...
21
votes
2answers
4k views

Who did async/await first?

Python added the async/await constructs in 3.5 in 2015. The Javascript community made steps towards it for a bazzillion years and finally added a very similar implementation to the draft in ES8 ...
3
votes
1answer
132 views

Future/Promise objects in Controllers - Best practice - MVC [closed]

I was going through some articles related to Futures and Callables today and was thinking about the best practices when working in an MVC based environment. I was wondering, should one be creating ...
2
votes
3answers
152 views

How are new bounded contexts deployed, and bugs fixed, in message-driven “autonomous” microservice architectures?

I'm coming from the monolith background, using a single large relational database. From my research, many proponents of the microservice architecture favor the event-driven rather than REST driven ...
1
vote
1answer
134 views

sequential command processing with an async io cloud upsert

We are new to c# and still trying to grok the async idioms. We have a windows service that requires us to iterate a list of results queried from a PC database to feed the parse cloud server (which ...
2
votes
2answers
488 views

When consuming an api, what is a good way to deal with their request limits?

My app is consuming a third party api. One of the requirements of this api is that my app cannot send more than 20 requests per second. Because of the nature of this app, and because my user base is ...
3
votes
1answer
677 views

Is it generally bad to await async operations in background processing (not needing the result)

So I've been working with background processing and event-driven systems, namely Azure WebJobs and ServiceBus. And while there is extensive use of async/await programming, I'm always wondering if it ...
0
votes
1answer
1k views

How to avoid synchronous communication between microservices

Let's say we're talking about a webshop. Microservice 1: Manages products and their prices Microservice 2: Responsible for payment and checkout. If a user wants to pay for a product, the payment ...
0
votes
1answer
142 views

How do I not lose the “reactive” nature of my services, simply because one of the services isn't reactive?

I've lately been very interested in reactive microservice design with streaming and event-driven architectures. When one writes (i.e., manages) services, this paradigm works extremely well by simply ...
3
votes
2answers
879 views

CQRS async query from command handler

In a CQRS/async microservices context, I have a command handler e.g. SendOrderConfirmationEmailCommandHandler implemented in a communications service. This depends on information from the orders ...
0
votes
2answers
686 views

When to check if the user is logged in?

I have an app with an optional login where some functionality requires the user to login. When checking if the user is logged in I use a framework that runs an async function that requests an access ...
3
votes
1answer
156 views

Design for avoiding concurrent calls to an interface implementation

The application I'm developing requires that some data is obtained through different channels. As this is a network process, I have decided to use async programming. I have designed the following ...
2
votes
1answer
56 views

How do I approach polyglot plugins for asynchrous python applications?

I've been looking at ways to let my app's users write plugins for it. However, to give them more options, I decided to implement a polyglot plugin system. From the engineering perspective there are ...
1
vote
1answer
185 views

How do I set up short-lived queues?

This scenario seems pretty ordinary, and yet, strangely, messaging systems (like Google Cloud PubSub and Task Queues and ActiveMQ) do not seem to support it -- they assume that topics/queues are long-...
0
votes
1answer
1k views

An elegant way to detect the end of an asynchronous recursive file search?

Given a recursive subroutine in single threaded environment which starts numerous asynchronous I/O operations and registers callback functions for each of them. This callbacks will be called on the ...
-1
votes
2answers
629 views

Straight line coding - How multithreading simplify asynchronous workflow?

Java author mentions: Threads can simplify the development of complex systems by turning complicated asynchronous code into simpler straight-line code. Again the book says: Threads make it easier to ...
3
votes
1answer
286 views

Composable asynchronous programming in Java without too much GC

Assume I'm writing a library in Java for performing network calls. I want it to be efficient for cases like highly loaded reverse proxies etc (10s to 100s Krps coming in and out; client requests ...
0
votes
1answer
993 views

Best practice to callbacks in OOP (JavaScript)?

For anyone who uses callbacks, how do I approach it when the method is an asynchronous setter? Here's an example class API { constructor() { this.token = null; } refreshToken(callback) ...
4
votes
1answer
24k views

Correct usage of async/await and Task.Run()

I am developing an application that will read excel files from disk and then process tests based on the data in the files. In order to keep the user interface from locking up when loading files and ...
5
votes
4answers
3k views

How do I know if my async function is truly asynchronous?

I'm writing a function in the node.js-style asynchronous way, but how do I know if these functions are truly asynchronous, i.e., that they run in parallel and not sequentially? Here is my code (...
3
votes
3answers
626 views

Is there a pattern for a chain of asynchronous calls, followed by a cleanup?

I have two asynchronous tasks that need to get completed - say they're "make a pie" (make) and "bake a pie" (bake). I also need to cleanup after everything's done - "clean the kitchen" (cleanup). bake ...
4
votes
3answers
1k views

Providing a non-blocking IO API in a C library

I am working on a C library (SlipRock) for interprocess communication. The library currently exposes a simple, blocking API. This is easy to use, makes misuse (relatively) difficult (this is C after ...
6
votes
3answers
983 views

Why do many languages semantically distinguish “async” functions from “non-async” ones?

I've seen this in C#, Hack, and now Kotlin: await or an equivalent operation can only be performed in special "async" contexts. Return values from these are, to borrow Hack's terminology, "awaitable" ...
4
votes
2answers
231 views

Design of asynchronous component

I'm trying to design an asynchronous component. Requirements on this component are : Component might receive events at any point in time Component might start a long-running operation and wait for ...