rename sharedds to threadproxyds

This commit is contained in:
Jaremy Creechley 2023-08-29 12:50:36 -07:00
parent ae584e900a
commit 0f32ea2344
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 17 additions and 17 deletions

View File

@ -22,30 +22,30 @@ export key, query
push: {.upraises: [].} push: {.upraises: [].}
type type
SharedDatastore* = ref object of Datastore ThreadProxyDatastore* = ref object of Datastore
# stores*: Table[Key, SharedDatastore] # stores*: Table[Key, ThreadProxyDatastore]
tds: ThreadDatastorePtr tds: ThreadDatastorePtr
method has*( method has*(
self: SharedDatastore, self: ThreadProxyDatastore,
key: Key key: Key
): Future[?!bool] {.async.} = ): Future[?!bool] {.async.} =
return success(true) return success(true)
method delete*( method delete*(
self: SharedDatastore, self: ThreadProxyDatastore,
key: Key key: Key
): Future[?!void] {.async.} = ): Future[?!void] {.async.} =
return success() return success()
method delete*( method delete*(
self: SharedDatastore, self: ThreadProxyDatastore,
keys: seq[Key] keys: seq[Key]
): Future[?!void] {.async.} = ): Future[?!void] {.async.} =
return success() return success()
method get*( method get*(
self: SharedDatastore, self: ThreadProxyDatastore,
key: Key key: Key
): Future[?!seq[byte]] {.async.} = ): Future[?!seq[byte]] {.async.} =
@ -64,7 +64,7 @@ method get*(
return success(data) return success(data)
method put*( method put*(
self: SharedDatastore, self: ThreadProxyDatastore,
key: Key, key: Key,
data: seq[byte] data: seq[byte]
): Future[?!void] {.async.} = ): Future[?!void] {.async.} =
@ -84,13 +84,13 @@ method put*(
return success() return success()
method put*( method put*(
self: SharedDatastore, self: ThreadProxyDatastore,
batch: seq[BatchEntry] batch: seq[BatchEntry]
): Future[?!void] {.async.} = ): Future[?!void] {.async.} =
raiseAssert("Not implemented!") raiseAssert("Not implemented!")
method close*( method close*(
self: SharedDatastore self: ThreadProxyDatastore
): Future[?!void] {.async.} = ): Future[?!void] {.async.} =
# TODO: how to handle failed close? # TODO: how to handle failed close?
echo "ThreadDatastore: FREE: " echo "ThreadDatastore: FREE: "
@ -106,9 +106,9 @@ method close*(
proc newSharedDataStore*( proc newSharedDataStore*(
ds: Datastore, ds: Datastore,
): ?!SharedDatastore = ): ?!ThreadProxyDatastore =
var self = SharedDatastore() var self = ThreadProxyDatastore()
let value = newSharedPtr(ThreadDatastore) let value = newSharedPtr(ThreadDatastore)
echo "\nnewDataStore: threadId:", getThreadId() echo "\nnewDataStore: threadId:", getThreadId()

View File

@ -9,18 +9,18 @@ import pkg/stew/results
import pkg/stew/byteutils import pkg/stew/byteutils
import pkg/datastore/memoryds import pkg/datastore/memoryds
import pkg/datastore/sharedds import pkg/datastore/threadproxyds
import ./dscommontests import ./dscommontests
import ./querycommontests import ./querycommontests
import pretty import pretty
suite "Test Basic SharedDatastore": suite "Test Basic ThreadProxyDatastore":
var var
sds: SharedDatastore sds: ThreadProxyDatastore
mem: MemoryDatastore mem: MemoryDatastore
res: SharedDatastore res: ThreadProxyDatastore
key1: Key key1: Key
data: seq[byte] data: seq[byte]
@ -50,11 +50,11 @@ suite "Test Basic SharedDatastore":
# res3.cancel() # res3.cancel()
# # print "res3: ", res3 # # print "res3: ", res3
suite "Test Basic SharedDatastore": suite "Test Basic ThreadProxyDatastore":
var var
memStore: MemoryDatastore memStore: MemoryDatastore
ds: SharedDatastore ds: ThreadProxyDatastore
key = Key.init("/a/b").tryGet() key = Key.init("/a/b").tryGet()
bytes = "some bytes".toBytes bytes = "some bytes".toBytes
otherBytes = "some other bytes".toBytes otherBytes = "some other bytes".toBytes