Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

expose a server object #2

Open
technoweenie opened this Issue Nov 23, 2011 · 2 comments

Comments

Projects
None yet
2 participants
Contributor

technoweenie commented Nov 23, 2011

I'm not a fan of how everything is inside workerThread(). I'd like to do a few things, but I wanted to get your thoughts first:

db = leveldb.LevelDB(options.dbfile)
server = leveldbServer(db)

# custom command
def incr(db, key):
    value = int(db.Get(key))
    value = value + 1
    db.Put(key, str(value))
    return value

# binds incr() to the incr command
server.command('incr', incr)

workers = []
    for i in xrange(3):
        worker = workerThread(context, server)
        worker.start()
        workers.append(worker)

The actual server object shouldn't really care what type of socket it uses. We can run tests (with nose, or something) against a server using a simple req/rep socket, and skip all the broker nonsense. Maybe I want to run the server with something other than xreq in production? Maybe I want to add custom commands to the server?

Thoughts?

Owner

srinikom commented Nov 23, 2011

Love the incr command. Meant to do it. Pls send the pull request. I should be able to merge.

On the server object I wanted to stick to leveldb command set and keep the async nature. If we remove the broker, I am afraid, client might unnecessarily block. Also, I am planning to implement serialization(some simple fifos) to increase the throughput. We can run tests and pick the best option.

Contributor

technoweenie commented Nov 23, 2011

I don't want to remove any of that. I just don't want the run() function of the workerThread to do all the work. I'll send a pull and see if that makes more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment