I am converting .net program in to node js
In .Net I used a blocking collection to keep 3rd party objects and it gives one object per request and waits until it filled.
BlockingCollection<DBAPP> DbDriverPool; //I can keep around 80 objects in that pool. (Due to memory usage)
MyProcess(){
Var obj = DbDriverPool.Take();
//do taks
DbDriverPool.Add(obj)
}
Every request will get separate obj and requests which doesn't have obj will wait until free obj is added to BlockingCollection.
I do not want to keep obj in nodejs like this. I only need a function to return integer between 0-80 for each concurrent request and rest of request should wait until integer is available.
(I am completely new to node js and also for javascripts) Can someone explain me how to do this?
> I am converting .net program in to node js
>
> In .Net I used a blocking collection to keep 3rd party objects and it gives one object per request and waits until it filled.
>
> BlockingCollection<DBAPP> DbDriverPool; //I can keep around 80 objects in that pool. (Due to memory usage)
>
> MyProcess(){
>
> Var obj = DbDriverPool.Take();
>
> //do taks
>
> DbDriverPool.Add(obj)
>
> }
>
>
> Every request will get separate obj and requests which doesn't have obj will wait until free obj is added to BlockingCollection.
>
> I do not want to keep obj in nodejs like this. I only need a function to return integer between 0-80 for each concurrent request and rest of request should wait until integer is available.
>
> (I am completely new to node js and also for javascripts) Can someone explain me how to do this?
There are many npm modules that others have written to solve resource-pool problems. Here's one:
https://www.npmjs.org/package/ generic-pool
>
> In .Net I used a blocking collection to keep 3rd party objects and it gives one object per request and waits until it filled.
>
> BlockingCollection<DBAPP> DbDriverPool; //I can keep around 80 objects in that pool. (Due to memory usage)
>
> MyProcess(){
>
> Var obj = DbDriverPool.Take();
>
> //do taks
>
> DbDriverPool.Add(obj)
>
> }
>
>
> Every request will get separate obj and requests which doesn't have obj will wait until free obj is added to BlockingCollection.
>
> I do not want to keep obj in nodejs like this. I only need a function to return integer between 0-80 for each concurrent request and rest of request should wait until integer is available.
>
> (I am completely new to node js and also for javascripts) Can someone explain me how to do this?
There are many npm modules that others have written to solve resource-pool problems. Here's one:
https://www.npmjs.org/package/
댓글 없음:
댓글 쓰기