[asterisk-scf-dev] Changes regarding state replicator keys

David M. Lee dlee at digium.com
Mon Dec 13 13:37:50 CST 2010


On Dec 13, 2010, at 12:01 PM, Mark Michelson wrote:

> 1) Instead of using a templated type for the key, use std::string. 
> std::string has a .c_str() method that will give a const char * to the 
> actual string content, and std::string has a size() method for reporting 
> the size of the string.

+1.  If you have some class you want to use for your identifier, you just need to make sure that you can convert that class to std::string.

Conversions from std::string to the id class are probably an anti-pattern, since you're then using the identity column for more than just identity.  You can easily put such information in the value that's being stored, so that's not too limiting.

> 2) Instead of using a templated type for the key, define a StateItemKey 
> class in slice. Each component that provides replicated items will also 
> define a subclass (or potentially more if it makes sense) of 
> StateItemKey that has whatever information they wish to use to identify 
> an item. By defining the key type as a slice class, this allows for the 
> Ice streaming interface to convert the object into a byte stream. Its 
> size can be determined from the resulting byte stream.

Meh.

> 3) Don't make any changes to the state replicator code. Instead, in the 
> memcached storage implementation, create a std::string key for every 
> opaque state item key received. Then keep a map of local string keys and 
> their matching opaque state item keys. Whenever an operation is invoked 
> on the memcached state replicator that involves a key, first find the 
> corresponding string key and then use that key for the calls into 
> libmemcached.

Wouldn't that defeat the purpose of using memcached?  If the state replicator ever failed, it would not be able to load state from memcached to restore its state.

dave
<><





More information about the asterisk-scf-dev mailing list