Thinking About GServer

Discussion in 'Ruby' started by James Edward Gray II, Nov 19, 2004.

  1. I need to code up a server. It could have as many as fifty
    simultaneous users all sending in commands. Those commands need to be
    processed in the order received, and many logged-in users may see
    changes based on the processing of those commands.

    I can code all this myself, I'm sure, but I thought I would have a look
    at GServer. It looks to simplify server setup and incoming reads, but
    it doesn't seem to offer any help for output. Am I reading this right?

    My plan for handling input is to push all commands onto a thread safe
    queue and have the main event thread pull them off the other end one at
    a time. But let's say that an event affects users A, B, and C. How do
    I notify them all?

    Do I cache their sockets when they log in, by name, and then write to
    each of those when the time comes? Those writes would need to be
    threaded I suppose, to avoid blocking the event thread.

    I guess mainly what I'm asking is, I need to roll all this output
    handling on top of GServer, if I want to use it, right?

    Thanks.

    James Edward Gray II
     
    James Edward Gray II, Nov 19, 2004
    #1
    1. Advertising

  2. James Edward Gray II wrote:
    > I need to code up a server. It could have as many as fifty simultaneous
    > users all sending in commands. Those commands need to be processed in
    > the order received, and many logged-in users may see changes based on
    > the processing of those commands.
    >
    > I can code all this myself, I'm sure, but I thought I would have a look
    > at GServer. It looks to simplify server setup and incoming reads, but
    > it doesn't seem to offer any help for output. Am I reading this right?
    >
    > My plan for handling input is to push all commands onto a thread safe
    > queue and have the main event thread pull them off the other end one at
    > a time. But let's say that an event affects users A, B, and C. How do
    > I notify them all?
    >
    > Do I cache their sockets when they log in, by name, and then write to
    > each of those when the time comes? Those writes would need to be
    > threaded I suppose, to avoid blocking the event thread.
    >
    > I guess mainly what I'm asking is, I need to roll all this output
    > handling on top of GServer, if I want to use it, right?


    Have you considered, at least for prototyping, using drb, with the
    thread-safe queue being the object exposed to clients (i.e.,
    DRbUndumped) by drb? The client code would push commands onto this
    queue, and the server would pull them off. The command object could
    contain a reference to a DRbUndumped object that stays on the client
    side. The server calls methods on this object to notify the client.
    (Another approach is to use yield: the client provides a block, and the
    server yields to it, passing a notification value.)

    For 50 clients, this might be less responsive than using GServer, though.
     
    Joel VanderWerf, Nov 19, 2004
    #2
    1. Advertising

  3. On Nov 18, 2004, at 6:39 PM, Joel VanderWerf wrote:

    > Have you considered, at least for prototyping, using drb, with the
    > thread-safe queue being the object exposed to clients (i.e.,
    > DRbUndumped) by drb?


    I should have specified this in my original message, my bad. My server
    needs to be reachable with simple Telnet.

    James Edward Gray II
     
    James Edward Gray II, Nov 19, 2004
    #3
  4. Hi James,

    --- James Edward Gray II <>
    wrote:

    > My plan for handling input is to push all commands
    > onto a thread safe
    > queue and have the main event thread pull them off
    > the other end one at
    > a time. But let's say that an event affects users
    > A, B, and C. How do
    > I notify them all?


    I may not be reading this right (ignorant me ;-) but
    it sounds something like Ara Howard's rq package:

    http://raa.ruby-lang.org/project/rq/

    Again, apologies if that is not you meant.

    > James Edward Gray II


    -- shanko
    >
    >





    __________________________________
    Do you Yahoo!?
    The all-new My Yahoo! - Get yours free!
    http://my.yahoo.com
     
    Shashank Date, Nov 19, 2004
    #4
  5. Shashank Date wrote:
    > Hi James,
    >
    > --- James Edward Gray II <>
    > wrote:
    >
    >
    >>My plan for handling input is to push all commands
    >>onto a thread safe
    >>queue and have the main event thread pull them off
    >>the other end one at
    >>a time. But let's say that an event affects users
    >>A, B, and C. How do
    >>I notify them all?

    >
    >
    > I may not be reading this right (ignorant me ;-) but
    > it sounds something like Ara Howard's rq package:
    >
    > http://raa.ruby-lang.org/project/rq/


    I think that requires all processes to access the queue on an nfs share.
     
    Joel VanderWerf, Nov 19, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Pence
    Replies:
    2
    Views:
    104
    Edward Faulkner
    Sep 28, 2005
  2. XiaoLiang Liu
    Replies:
    6
    Views:
    133
    XiaoLiang Liu
    Mar 26, 2008
  3. Iñaki Baz Castillo
    Replies:
    2
    Views:
    124
    Iñaki Baz Castillo
    Mar 27, 2008
  4. Victor Reyes

    TCP Server/GServer

    Victor Reyes, May 24, 2008, in forum: Ruby
    Replies:
    3
    Views:
    166
    Victor Reyes
    May 27, 2008
  5. optimistx

    Linear thinking vs essential thinking

    optimistx, Oct 28, 2009, in forum: Javascript
    Replies:
    4
    Views:
    186
    Dr J R Stockton
    Oct 29, 2009
Loading...

Share This Page