* refactor: change rpc protocol to send progress on provide
* WIP add progress
* WIP more hacking in progress work
* WIP more progress
* WIP add the actual progress tracking
* progress finished
* refactor: move ProvideResponse / ProvideResponseEntry out of the RPC protocol
* validate progress
- generate events
* Add nice validate progress
* refactor: simplify provide code
* pr: review comments from this PR and last one
* refactor: change rpc protocol to send progress on provide
* WIP add progress
* WIP more hacking in progress work
* WIP more progress
* WIP add the actual progress tracking
* progress finished
* refactor: move ProvideResponse / ProvideResponseEntry out of the RPC protocol
* refactor: simplify provide code
* feat(persistence): copy over directory functions from beetle
* feat: add snapshot type that deals with persistence
* test(persistence): add property based tests for db persistence
* feat(persistence): basic persistence works
* Make provider cloneable
* refactor:
provider is getting to big, so give it its own submodule and put database
in there.
* clippy
* fix: disable persistence in cli tests
* refactor: make the snapshot stuff just pub(crate)
so we don't bloat the public API
* fix: properly handle when iroh data dir does not exist yet
Also fix mixup of dir names
* fix: persist key in iroh data root if persistence is on
* feat: canonicalize before adding collection
Not saying that we should suddenly start to care about canonicalization, but
it is almost free, so we might as well do it.
* feat: allow deep directory structures
* fix: make sure deep directories are created
* refactor: use walkdir
* pr: remove unused dev dependency and dead code annotation
* test: add basic test for persistence
* pr: remove key and persist options
it will now always persist.
Also fix the test by not mixing sync and async.
* refactor: get rid of collection name
The name should be external
* refactor: make fields in Collection private
...so we can canonicalize it
* ci: change toolchain for doc to stable
* refactor: canonicalize collection on create
conceptually, a collection should be a set of name -> blob mappings that
is sorted by name. We could use a BTreeMap or a RadixTree later.
* fix: special handling for single files
* doc: add comment about traversal
* feat: properly handle windows insanity
* Add basic test for canonicalize_path
* test: add a test that sends a (tiny) hierarchy
* refactor: runtime check for duplicate names
* pr review: minor changes and comments
* refactor: get rid of collection name
The name should be external
* refactor: make fields in Collection private
...so we can canonicalize it
* ci: change toolchain for doc to stable
* feat(persistence): copy over directory functions from beetle
* feat: add snapshot type that deals with persistence
* test(persistence): add property based tests for db persistence
* feat(persistence): basic persistence works
* Make provider cloneable
* refactor:
provider is getting to big, so give it its own submodule and put database
in there.
* clippy
* fix: disable persistence in cli tests
* refactor: make the snapshot stuff just pub(crate)
so we don't bloat the public API
* fix: properly handle when iroh data dir does not exist yet
Also fix mixup of dir names
* fix: persist key in iroh data root if persistence is on
* feat: validation of database
* feat: add nicer output for validate
* pr: remove unused dev dependency and dead code annotation
* test: add basic test for persistence
* pr: remove key and persist options
it will now always persist.
Also fix the test by not mixing sync and async.
* pr: address PR issues
- styled output
- comments
- no big buffer on stack
* doc: add todo for commented out errors that need to be done
* feat(persistence): copy over directory functions from beetle
* feat: add snapshot type that deals with persistence
* test(persistence): add property based tests for db persistence
* feat(persistence): basic persistence works
* Make provider cloneable
* refactor:
provider is getting to big, so give it its own submodule and put database
in there.
* clippy
* fix: disable persistence in cli tests
* refactor: make the snapshot stuff just pub(crate)
so we don't bloat the public API
* fix: properly handle when iroh data dir does not exist yet
Also fix mixup of dir names
* fix: persist key in iroh data root if persistence is on
* pr: remove unused dev dependency and dead code annotation
* test: add basic test for persistence
* pr: remove key and persist options
it will now always persist.
Also fix the test by not mixing sync and async.
* feat: add shutdown command
hard for process exit, soft for graceful shutdown
* feat: add id command
currently it prints exactly the same thing as provide prints on startup
* pr and clippy:
rename hard to force, and avoid giant enum for IdResponse
* Allow disabling rpc by passing 0 for rpc-port
* review: make a special enum so rpc port can be disabled with "disabled"
* pr: impl Into<Option> instead of having a named fn
* ref: use separate alpn for rpc calls
* feat: pass errors to the client
* Add comment about path
* feat: copy over the watch and version stuff from iroh
This is so we can detect if the sendme server is running
* docs: add todo about better way to check the server is available
* refactor: update to new quic-rpc
* refactor: move RpcError and RpcResult to util
* refactor: prettify the code a bit
* feat: print peer id and address and stuff on startup
* refactor: make a constant for RPC port
* refactor: Put RPC_ALPN into a const
* fix: use Ipv4Addr::LOCALHOST on server
* fix: ipv6
* refactor: Use RwLock instead of mutex
Should help a bit, so why not?
* feature: make rpc port configurable
* add ability to talk to provider internally via the RPC interface
* adapt cli tests
* review comments
* docs: Add some docs for why we need to wait when closing a rpc client
* feat: nicer output for add and provide
* clippy
* fix: better output for list
* refactor: remove the delay when dropping the client
This now gets taken care of in quic-rpc. The shutdown_timeout is good to
limit the time for a clean shutdown so we don't have to wait indefinitely.
Before going into the loop we may as well make sure to reserve enough
space for the entire buffer. Otherwise we could be allocating
multiple times.
This does not change the total allocated size. Though this does add a
missing limit to the allocated size.
This simply delegates to eprintln! for writing output. This ensures
writes happen more synchronously and the flaky integration tests are
fixed.
While in theory these are blocking operations on the async executor,
this is acceptable because:
- We already use println!() without any problems. Arguably this is
more of an issue since we also write data to stdout but it isn't
because we don't do that at the same time.
- We print a small number of messages, not large amounts of data. Any
blocking from this will be small.
- This acquires a sync mutex while writing, that's fine because it is
acquired and released in the same chunk of async code and not held
across await points. This is unlikely to block much as only main
writes and only one write happens at a time.
- When logging via tracing is enabled this will also end up logging on
here and will compete for the lock. This is slightly higher
contention but doesn't really interfere with the logging here.
Seems like we ended up with two bits of code doing exactly the same.
Clean it up.
This settles on read_lp() as name since this is symmetric with
write_lp() which writes bytes. This implementation inlines the
functions a bit more as well, the entire function is still small and
it is used often.
* refactor: replace out_writer with a out_println! macro
* refactor: rename out_println! to progress!
It does not really write to stdout but to stderr, so out...anything is a
bit misleading.
Tests the provide-get loop, transferring a single file, a folder of multiple files, and data from stdin of the provider to stdout if the better, ensuring that the content is transferred successfully.
The tests also test the stdout of the provider and stderr of the getter, using regex matching on each line of the respective output.
This fixes the log message output which had an extraneous newline in
it and needlessly used debug output.
It also adds the listening address to the normal provider output: This
is universally useful since you can specify addresses with -a but
don't otherwise know which one is used if using OS-allocated ports.
This can also be useful for testing.
This makes sure the OutWriter writes the newline as part of the same
buffer as the output. This makes it less likely that the output will
be interrupted between the content and the newline. E.g. without this
and enabling logging, log messages will be injected between the
content and the newline, making the output garbled.
Unfortunately this isn't entirely correct and is more of a heuristic
because most of our output is small enough that they fit in a single
write. In the blocking world you'd lock Stderr while printing the
messages, in the tokio world however I don't know how to safely do
this.