Singleton instance of controller per user for Ajax request in Grails? -


i writing small grails application small number of users (max 10). hosted on heroku free hosting (1 dyno=512 mb ram).

the app have 1 user form on submit trigger ajax request spawns thread in controller.(the default submit action prevented via preventdefault() because task time consuming , heroku has timeout of 30s).

for example thread fetches list of items external api/url, controller have instance variable itemfetched. webpage of user form contain progress widget periodically show value of itemfetched.

usera starts thread , while running in background, user see status of itemfetched when leaves page , hits url again.

how create "per user" controller (as long thread spawned via ajax thread running), rather per http request (i.e. prototype scope)?

in particular situation session scoped service perfect fit. can read more in documentation.

by making service session scoped, each http session have it's own instance of service , can maintain state between requests within given session.


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -