Kinetic / kinetic-py

Kinetic Python Library
http://seagate.github.io/kinetic-py
22 stars 10 forks source link

[Feature Request] Async commands should return command sequence numbers #21

Open rpcope1 opened 10 years ago

rpcope1 commented 10 years ago

Nacho,

One things that would be helpful would be if for each async command, we were returned the sequence number used to send the command. While I can't build my callback functions directly with the sequence number now (perhaps you could add a function to get the next possible sequence number), I could add each sequence number into a queue, and pop numbers off as messages are received. If I had a command fail to come back, it should be pretty straightforward for the user to build up the framework to figure this our relatively quickly.

Example:

 my_queue = Queue.Queue()
 client = kinetic.ThreadedClient('192.168.128.10')
 for I in xrange(100):
    #blah blah blah build up callback handlers with keys and values
    seq_num = client.putAsync(key, value, success_handler(my_queue, i), failure_handler(my_queue, i))
    my_queue.put((seq_num, i))
 #Watch for callbacks to come back, if something fails, track it back to individual sequence number.```
icorderi commented 10 years ago

You already solved your need in your own example.

client.putAsync(key, value, success_handler(my_queue, i),failure_handler(my_queue, i))
my_queue[i] = "some state"

You don't need the clients internal sequence number.

rpcope1 commented 10 years ago

For doing debug, especially against the drive, I think it would be good to have the ability to explicitly expose the sequence numbers. I also think the development team agrees with this, as it allows you to look inside the drive or simulator and match up requests on the drive/simulator to requests at the client level.