had a date night last night and probably drank a bit too much. my wife followed me on the bike while we did some errands as well. hot and humid this afternoon which really dragged me down. i'll finish the rest of the HM at home.
#running
# 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 238464 # self = https://watcher.sour.is?offset=232538 # next = https://watcher.sour.is?offset=232638 # prev = https://watcher.sour.is?offset=232438
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
*
twt.Attrs().Get("lang")
twt.Attrs().Get("lang")