I'm having some issues regarding how and when sync events are fired. Is this something that is caused by the user doing some sort of input? I seemed to find stuff on Google's dev docs about sync events firing when you have internet again (if you lose the internet). Is this the case for desktop? Or is it just for mobile?
Related
My Rails App syncs calendar events from gmail through the Nylas API. I am storing all the events and associated calendars on my app (either creating new or updating existing). It takes a very long time, in fact, I get timeout errors on my Heroku hosted Rails App whenever I try to sync a calendar. Not sure why it takes a very long time. So to react, I want to either start caching (using Redis or Memcached) the data (still don't know exactly how I will do that) OR run the sync in a background job (using Delayed_Job or Resque).
I wanted to know how others would tackle this problem. Would appreciate some feedback on not only what approach to take, but pointers in how would be appreciated as well.
If you need fast, persistent access within your app to a large set of calendar events that are ultimately sourced from an external system, then I'd create (in fact have already created) models for the calendars and the events. The structure ought to be fairly obvious from the structure of the API, and I would just persist them in your database so you can use ActiveRecord methods to retrieve/sort them.
It's unlikely that you'd need a caching layer on top of the model.
Synchronisation is definitely a background job.
You can use both but majorly background jobs, delayed_job or sidekiq.
You can also run a cron task that periodically update the calendar data in your app.
To fetch data you can fetch from memory store then database, where memcache will be useful.
I'm developing an ASP.NET MVC 5 application that displays current staffing data, and uses SignalR to notify connected clients when staffing changes occur. This is working great for real-time events ("I need to leave work now."), but now I need to handle scheduled events where a staffing change will happen in the future.
That is, an event may be scheduled to occur in 3 hours and 27 minutes ("I need to leave work at 4pm") or even 3 months from now. When the event occurs, connected clients should be notified in order to display correct staffing data to the end users. Of course, the future may change, and a solution would need to account for scheduled events being canceled or modified.
I would love to find a clean way to do this that doesn't involve frequent polling from clients to learn of upcoming events, a thread on the server side that sleeps, etc.
I would create a small windows service that takes care of scheduling. Then use a service bus to signal the web server for example
http://ayende.com/blog/3752/rhino-service-bus
On the web server you can use https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy
to forward the messages directly to the clients
I built a Windows Service, let's call it Jobs. And I have a WinForm app, let's call it Viewer.
I want Viewer to receive events from Jobs when Jobs starts executing something so Viewer can display to the user that Job A started, did something, stopped, etc.
Is there a way to have Jobs throw events that Viewer can register to receive? The best solution I can think of is using MSMQ, however I'd like a more direct approach where I startup Viewer and it registers with the Jobs windows service and asks to receive notifications/events from it.
I can't seem to figure out how to get a Windows Service to Push something without using MSMQ, or to have others programs register with it to receive Pushes. I definitely do NOT want to use some weird file and/or database system where Viewer sleeps for 5 seconds and then checks for changes. I want something streamlined where Viewer Waits for Events, but does not have to use the MSMQ.
You can use one of the WCF duplex bindings for this, such as netTcpBinding or dualHttpBinding. There is a full example here which would seem to do exactly what you want.
The drawback is that duplex is complex to understand and may not be that reliable. I would always implement a solution using one way communication (either via queueing or some other mechanism) if it was an option to do so. One way is always simpler and more reliable than duplex.
I have a Windows service that performs various "jobs" for my application (send emails, create backups, check for my application updates, provide some services...)
Recently some costumers reported problems between using some Internet banking sites and my application.
In searching for solutions, I found reports about a plugin (ActiveX) installed by the Internet banking Web site.
This ActiveX installs a bizarre service (GbPlugin, from GAS Tecnologia), that kills suspicious applications based in some idiot heuristic, and my service is a victim!
Now I'm trying to "immunize" my service.
Are there some ways to restrict the termination of my service to protect it?
I cannot use the "auto restart" option in the service properties, because I cannot be killed!
Both services are running as LOCALSYSTEM.
Most likely that service runs as LOCALSYSTEM and so can kill anything it likes. So it's extremely unlikely that you can defend against it.
Indeed, a quick websearch throws up some some hits that indicate that the service does indeed run as LOCALSYSTEM.
Your only tenable solution is going to involve the other software. Either compel your users to remove it, or work with its developers to find a way to white-list your program.
Assuming GbPlugin is going through normal SCM procedures to stop services and not just brute-force terminating them, then you have a couple of choices to prevent your service from stopping:
set your service's AllowStop property to False.
in the OnStop event, set the Stopped parameter to False.
Either approach will also prevent you from stopping your own service under normal consitions. To work around that, you could write a separate app that uses the Win32 API ControlService() function to send a custom command to your service. Inside your service, have it override the virtual DoCustomControl() method to look for that command. Have it either reset the AllowStop property back to True, or set a flag somewhere that the OnStop event can look at, then call Controller(SERVICE_CONTROL_STOP) to initiate a normal stop.
Needless to say, this is a bit overkill. If possible, a better option is to simply contact GAS Tecnologia and ask why your service is being flagged by GbPlugin's heuristics and then change that condition in your service, or else ask them to fix GbPlugin to ignore your service.
I'm writing a simple chat room application in Rails 3.1 - for learning purposes.
For starters I have all the needed models (messages, users, rooms, etc.) and things work great.
The clients poll the server every minute (for example) and get new messages if they have any.
I would like to change the simple polling to long polling and can't figure out if this can be done in the same app or do I have to create some other Push server for the long polling.
I read a lot about EventMachine and changed my rails app to user it as I wanted to use EventMachine for the event driven mechanics. I thought that the EventMachine channel would come in handy for this.
A client would connect and wait for a message in the chat room and it will receive a message only when one was sent to the room.
What I can't figure out is how can I share the EventMachine::Channel instance between all my client connections.
Is this approach even possible or am I going at it the wrong way?
If possible I would like a solution that can run as a single rails application hosted on Heroku.
Yeah sure. I just wrote a demo using event machine. My case is that player walking around a map, and other players should be able to see it.
The demo looks like that:
A client establishes a connection, reporting its own coordinate(generated randomly)
There is an array preserving all the coordinates for each client
When a client moves, it sends its new coordinate to the server. Then the server finds out people near him(from the array), and push the new coordinate to those clients.
I tested it with nearly 5000 clients, and each second 20-30 players moves its position. And the server process only takes less that 100M memory & 50%-60% cpu usage(on a single core).
In your case, I think you should probably try faye too. It's based on event machine, and an appropriate solution to things like chat room.
Expanding what I've mentioned on the comment, check this blog post that explains how to create a text based chat app using EM, and uses AMQP to broadcast the messages to the other users.
I think you can probably do the same or use some in memory queues to share messages, and this definitely should work on heroku, as you don't have a dependency to an external service such as RabbitMQ.
Here's a good discussion about different queue frameworks: ActiveMQ or RabbitMQ or ZeroMQ or
Rails will have streaming added in version 4.
For now, you can streaming (long polling) like in this example with Sinatra and Redis's Pub/Sub feature as a backend. You will have to add another action to handle user sent messages, adding them to Redis's with PUBLISH command. You should use an evented server like Thin or Puma.