finishing the 13 miles. this felt really easy on tired legs.
#running #treadmill
# I am the Watcher. I am your guide through this vast new twtiverse. # # Usage: # https://watcher.sour.is/api/plain/users View list of users and latest twt date. # https://watcher.sour.is/api/plain/twt View all twts. # https://watcher.sour.is/api/plain/mentions?uri=:uri View all mentions for uri. # https://watcher.sour.is/api/plain/conv/:hash View all twts for a conversation subject. # # Options: # uri Filter to show a specific users twts. # offset Start index for quey. # limit Count of items to return (going back in time). # # twt range = 1 194395 # self = https://watcher.sour.is?offset=186034 # next = https://watcher.sour.is?offset=186134 # prev = https://watcher.sour.is?offset=185934
storage
, that's it. Everything is in there. The only implementation so far is an SQLite backend that resides in storage
. My RAM storage is exactly that SQLite storage, but with :memory:
instead a backing file on disk. I do not have a mock storage (yet).tt
rewrite, too. Sigh. I just have the feeling that in storage/sqlite/sqlite_test.go I cannot import storage/mock for the helper because storage/mock/mock.go imports and embeds the type from storage/sqlite. But I'm too tired right now to think clearly.*
NewRAMStorage(…)
is just something that setups your storage and initial data.. that can probably live with storage/sqlite
. The point is the storage
package does not import the implementations of storage.Storage
It just defines the contract for things that use that interface. Now storage/sqlite
CAN import storage
and not have a circle dep.
- app < storage
< storage/sqlite
< controller < storage
< storage/sqlite
- sqlite < storage
- storage X storage/sqlite
NewRAMStorage(…)
is just something that setups your storage and initial data.. that can probably live with storage/sqlite
. The point is the storage
package does not import the implementations of storage.Storage
It just defines the contract for things that use that interface. Now storage/sqlite
CAN import storage
and not have a circle dep.
- app < storage
< storage/sqlite
< controller < storage
< storage/sqlite
- sqlite < storage
- storage X storage/sqlite
storage.Storage
Storage
interface (no tests!) storage.Storage
Storage
interface (no tests!) Storage
interfaceStorage
interfacenewRAMStorage(testing.T, $initialData) *Storage
Storage
newRAMStorage(…)
functionnewRAMStorage(…)
into aNewRAMStorage(…)
testutils.NewRAMStorage(…)
testutils.NewRamStorage(…)
teststorage
package imports storage
for storage.Storage
and the storage
package imports testutils
for testutils.NewRAMStorage(…)
in its test. I'm just screwed. For now, I duplicated it as newRAMStorage(…)
in controller/feeds_test.go.NewRAMStorage(…)
in storage/testutils.go, which could be guarded with //go:build testutils
. With go test -tags testutils …
, in storage/sqlite_test.go could just use NewRAMStorage(…)
directly and similarly in controller/feeds_test.go I could call storage.NewRamStorage(…)
. But I don't know if I would consider this really elegant.!prod
instead of testing. Only when building the final binary, I would have to specify the tag to exclude all the non-prod stuff. Hmmm.*
Storage
interfaceStorage
interfacenewRAMStorage(testing.T, $initialData) *Storage
Storage
newRAMStorage(…)
functionnewRAMStorage(…)
into aNewRAMStorage(…)
testutils.NewRAMStorage(…)
testutils.NewRamStorage(…)
teststorage
package imports storage
for storage.Storage
and the storage
package imports testutils
for testutils.NewRAMStorage(…)
in its test. I'm just screwed. For now, I duplicated it as newRAMStorage(…)
in controller/feeds_test.go.NewRAMStorage(…)
in storage/testutils.go, which could be guarded with //go:build testutils
. With go test -tags testutils …
, in storage/sqlite_test.go could just use NewRAMStorage(…)
directly and similarly in controller/feeds_test.go I could call storage.NewRamStorage(…)
. But I don't know if I would consider this really elegant.!prod
*