Previously, RedisDataSource::Create returned an expected<shared_ptr<RedisDataSource>, error>.
The idea was that DataSystem config accepts a shared_ptr (in theory, so that they don't have to give up management of the source's lifetime. TBD if this turns out to be helpful or not.)
We don't need to force the user into shared ownership in the factory function though - instead, return a unique_ptr and let them make the transformation.
Motivation is thatshared_ptr is painful with the C bindings. We get back a stack-allocated shared_ptr from the factory, and then need to heap allocate one so we cast it to the opaque type. This is not necessary if we just return a unique_ptr, since we can call .release() and then pass the unmanaged pointer around.
Previously,
RedisDataSource::Create
returned anexpected<shared_ptr<RedisDataSource>, error>
.The idea was that
DataSystem
config accepts ashared_ptr
(in theory, so that they don't have to give up management of the source's lifetime. TBD if this turns out to be helpful or not.)We don't need to force the user into shared ownership in the factory function though - instead, return a
unique_ptr
and let them make the transformation.Motivation is that
shared_ptr
is painful with the C bindings. We get back a stack-allocatedshared_ptr
from the factory, and then need to heap allocate one so we cast it to the opaque type. This is not necessary if we just return aunique_ptr
, since we can call.release()
and then pass the unmanaged pointer around.