Is it save to rely on the order of messages passed from the main thread to a single Web Worker being retained? For instance, if I do
worker.postMessage(1);
worker.postMessage(2);
will the worker certainly get to process the first message before the second one?
As long as you are working with the same worker to post the messages, I think it will. You can easily test this if you want. Make a loop and post messages with a certain order. If you always receive the messages in the same order as you post them, you can relay on it, that this will be the case.
Related
I'm new to NATS and have read all the examples for:
https://nats.io/documentation/concepts/nats-messaging/
I'm in Microservciearchitecture where in microservice-Y (MSY) need to store some information published from other microservice-X (MSX) I have 2-10 instances of MSY so when changes are made in MSX and MSX-instance publishes event I want that only 1 instance of MSY should save information so not all of them save the same data.
I have read Request-Repy:
https://nats.io/documentation/concepts/nats-req-rep/
but there seems that all of instances receives message (and will handle it) even if it is point-to-point and reply is handled just for the one instance that is quickest to reply
Is this correct or have I missunderstood example?
If I only need that 1 instance of MSY should handle given message (store data in db) what can I do to acheve this?
Use queue groups. If you have multiple subscriptions on the same subject with the same queue group, only one of the members of the group will receive the message.
Check this out: https://nats.io/documentation/concepts/nats-queueing/
I've written a script that sends an hourly email to me using:
MailApp.sendEmail("john#doe.com", "Status Update", currentStatus);
My only gripe is that every message I get is treated as a separate thread, despite the subject lines all being the same. I'd prefer if all were threaded so I can see the stream of messages in one place.
Is there any way to have new status messages appended to the same thread?
Will this require using GMailApp functions instead?
EDIT (2016-08-26): I have solved my problem using the following method/workaround:
Include a unique "marker" somewhere in the status message. I use a static UUID that I generated online.
Use GmailApp.search() to find the thread with the status message(s) by looking for the unique marker.
Use GmailApp.reply() to add a new status message to the thread.
This keeps all the status messages together as desired. Perhaps there's a more elegant way to do this but this works...
I have a senario that has been causing me issues for the last few weeks now. I currently have a "homepage" that populates with data from a controller with sports stats. This data comes from a service that is also used for the individuals pages for this sports stats.
For instance a user is able to click one of the listings on the home page and get a detailed list of that particualar entry with a state change from sports.com to sports.com/id/sport
I do this by taking the id from the home service and pass that through the paramenters within the state for the details page. From here I use that same service with the #id as a paramenter in order to get the details for that page (using $stateParams.id).
Normally that would work fine, but here is the problem. Sometimes when hitting the details page the service fires off the get request before the $stateParams.id is availibe and I end up with an error in my request. So instead of /json.php?detail=id im getting /json.php?detail=
For a cheap fix I now have the search query waiting on a timeout for 800ms in order to give the state time to resolve the $stateParams.id and then finally send out the request. My question is, what is a better way to do this? Is this something experienced often? It seems like in all my time with angular I haven't run into this situation so I'm a bit at a lost. Thanks
When a user calls my number, I wish to have Twilio <Say> something to them while <Dial>ing another number, the issue is, I can only seem to get it to do one or the other (I.E. Say, then dial (Delaying the dial), or, dial, then say (Not saying until the call is over)). What I want is either of the following (First one would be preferable, although answers to do both would be the best (In case I need the opposite one in the future/someone Googling)):-
Initiate the call to the new number AND start saying "Lorem ipsum...", if the say finishes first then silence until the call is picked up, if the phone number picks up first, let the say finish then transfer them/combine the calls.
Initiate the call to the new number AND start saying "Lorem ipsum...", if the say finishes first then silence until the call is picked up, if the phone number picks up first, cut the say command off and instantly transfer/combine the calls.
Thanks!
Twilio evangelist here.
There is no way to do this using just Twiml as Twilio processes Twiml sequentially so its going to finish the <Say> before moving on to the <Dial>.
You could combine Twiml with the REST API to do this however. In the same HTTP request where your generating the TwiML with the in it, you would also make a call out to the REST API to have Twilio start an outbound phone call.
Twilio would <Say> what you want to Caller A while dialing Caller B. When Caller B answers, put them into a conference. Once Caller A finishes listening to the <Say> put them into the same conference.
This way, regardless of who gets their first, Caller A or Caller B, either will wait for the other. You can use the StatusCallback parameter to detect if Caller B never answers and in that scenario redirect Caller A out of the conference.
Hope that helps.
Thanks for your reply for my question: Is this a bug of Box API v2 when getting events
This is a new problem related to this. The problem is that I cannot reliably use the next_stream_position I got from previous calls to track events.
Given this scenario:
Given the following two GET HTTP queries:
1. GET https://api.box.com/2.0/events?stream_position=1336039062458
This one returns the JSON file which contains one file entry of myfile.pdf and the next stream position = 1336039062934
2. GET https://api.box.com/2.0/events?stream_position=1336039062934
This call uses the stream position I got from the first call. However, it returns the JSON contains the exactly same file entry of myfile.pdf with the first call.
I think if the first call gives a stream position, it should be used as a mark for that exact time (say: TIme A). If I use that stream position in subsequent queries, no events before "Time A" should be returned.
Is this a bug? Or did I use the API in the wrong way?
Many thanks.
Box’s /events endpoint is focused on delivering to you a highly reliable list of all the events relevant to your Box account. Events are registered against a time-sequenced list we call the stream_position. When you hit the /events API and pass in a stream_position we respond to you with the events that happened slightly before that stream position, up to the current stream_position, or the chunk_size, whichever is lesser. Due to timing lag and our preference to make sure you don’t miss some event, you may receive duplicate events when you call the /events API. You may also receive events that look like they are ‘before’ events that you’ve already received. Our philosophy is that it is better for you to know what has happened, than to be in the dark and miss something important.
Box events currently give you a window roughly 5 seconds into the past, so that you don't miss some event.
We have considered just delaying the events we send you by about 5 seconds and de-duplicating the events on our side, but at this point we've turned the dial more towards real-time. Let us know if you'd prefer a fully de-duped stream, that was slower.
For now, (in beta) if you write your client to check for duplicate events, and discard them, that will be best. We are about to add an event_id to the payload so you can de-duplicate on that. Until then, you'll have to look at a bunch of fields, depending on the event type... It's probably more challenging that it is worth.
In order to help you be able to figure out if an event is a duplicate, we have now added to each event an event_id that will be unique. It is our intention that the event_id will allow you to de-duplicate the responses you receive from subsequent GET /events calls.
You can see this reflected in the updated documentation here, including example payloads.