/* Interface to Amazon S3 storage. */
/* Simple in-memory data store for test purposes. */
-struct S3Store {
+typedef struct {
S3BucketContext bucket;
-};
+} S3Store;
-struct S3Store *s3store_new()
+static gpointer s3store_new()
{
- struct S3Store *store = g_new(struct S3Store, 1);
+ S3Store *store = g_new(S3Store, 1);
store->bucket.bucketName = "mvrable-bluesky";
store->bucket.protocol = S3ProtocolHTTP;
store->bucket.uriStyle = S3UriStylePath;
return store;
}
+static void s3store_destroy(gpointer store)
+{
+ g_free(store);
+}
+
struct get_info {
gchar *buf;
gint offset;
return S3StatusOK;
}
-void s3store_response_callback(S3Status status,
+static void s3store_response_callback(S3Status status,
const S3ErrorDetails *errorDetails,
void *callbackData)
{
}
}
-BlueSkyRCStr *s3store_get(struct S3Store *store, const gchar *key)
+static BlueSkyRCStr *s3store_get(gpointer s, const gchar *key)
{
+ S3Store *store = (S3Store *)s;
+
struct get_info info;
info.buf = (char *)g_malloc0(BLUESKY_BLOCK_SIZE);
info.offset = 0;
return bluesky_string_new(info.buf, BLUESKY_BLOCK_SIZE);
}
-void s3store_put(struct S3Store *store, const gchar *key, BlueSkyRCStr *val)
+static void s3store_put(gpointer s, const gchar *key, BlueSkyRCStr *val)
{
+ S3Store *store = (S3Store *)s;
+
struct put_info info;
info.val = val;
info.offset = 0;
S3_put_object(&store->bucket, key, val->len, NULL, NULL,
&handler, &info);
}
+
+static BlueSkyStoreImplementation store_impl = {
+ .create = s3store_new,
+ .destroy = s3store_destroy,
+ .get = s3store_get,
+ .put = s3store_put,
+};
+
+void bluesky_store_init_s3(void)
+{
+ S3_initialize(NULL, S3_INIT_ALL);
+ bluesky_store_register(&store_impl, "s3");
+}