Commit Graph

66 Commits

Author SHA1 Message Date
Stanislau Hlebik
3c5f2212c0 mononoke: fix select_all()
Summary:
In previous diff upstream select_all() was added. However it had a bug.
In
```
match self.inner.poll() {
...
Async::Ready(_) => {
  return Async::Ready(None);
}
}
```

Async::Ready(None) was returned for the case when inner poll returned  `Async::Ready(None)`
and for the case when inner poll returned `Async::Ready(Some(None, remaining))`.
The former was correct, however the latter wasn't. `Async::Ready(Some(None, remaining))`
happens when one of the internal streams was exhausted, however there can be
many more internal streams that are not exhausted yet. Before this diff these
non-exhausted elements would be just lost, so this diff fixes it.

Reviewed By: farnz

Differential Revision: D7550918

fbshipit-source-id: 908af9fed17744b884aa40afdccfc4654520048b
2018-04-10 02:22:51 -07:00
Stanislau Hlebik
32a914edb6 mononoke: copy-paste select_all method from futures-0.2.0
Summary:
This is a simple but useful combinator that queries lots of streams in parallel
and merges the results.
This is code is taken from futures-0.2.0, but it was modified so that it works
with futures-0.1.*. It was re-formatted with our linter.

The code had a bug that will be fixed in the next diffs

Reviewed By: farnz

Differential Revision: D7550919

fbshipit-source-id: c5b394065c0184a89dfab6a9de699725bc2bd6c2
2018-04-10 02:22:51 -07:00
Simon Farnsworth
eb6cf294d3 Give ConservativeReceiever its own error type
Summary: We had a fun bit of debugging because an out-of-order `oneshot::recv()` gave a `oneshot::Canceled` error. Give it an enum for errors, so that we can distinguish dropping the rx channel from calling `oneshot::recv()` before `oneshot::send()`

Reviewed By: StanislavGlebik

Differential Revision: D7382354

fbshipit-source-id: c96f4ac40449a5864b7ba79f43f9af402de7735b
2018-03-26 06:21:20 -07:00
Lukas Piatkowski
d25ca34c0f bundle2-resolver: reorganize resolver for easier handling of BlobRepo::create_changeset
Reviewed By: farnz

Differential Revision: D7032695

fbshipit-source-id: 66a4d75004236536e5dca6da38f71e4662cda0c8
2018-02-22 04:53:56 -08:00
Lukas Piatkowski
ed54079826 futures_ext: added StreamExt::return_remainder
Summary: This new method is useful in my future work where I rely on this easy to use and readable API to be able to get over the fact that futures combinators take Stream by value. With this one can chain on the end of consuming Stream and by using the "remainder" Future get the consumed Stream.

Reviewed By: StanislavGlebik

Differential Revision: D6965532

fbshipit-source-id: 3ab19851b3d48c43c8d7e3a96ae5c03a7d242960
2018-02-14 06:31:41 -08:00
Lukas Piatkowski
0d8cc77882 future-ext: introduce ByteStream for efficient processing stream of bytes
Reviewed By: jsgf

Differential Revision: D6494542

fbshipit-source-id: d069137326697105a402261e4fbe69ab95ade67e
2018-01-15 10:36:32 -08:00
Lukas Piatkowski
533cad062f futures-ext: remove FramedStream and replace it's usages with tokio_io::codec::Framed
Summary: The Framed and FramedParts duet fits following diffs a bit better than FramedStream and ReadLeadingBuffer.

Reviewed By: jsgf

Differential Revision: D6567554

fbshipit-source-id: 88d117ad9e8227f9de278037b333da7ffc4fdf1f
2018-01-15 10:36:31 -08:00
Lukas Piatkowski
35e3c19f1c async-compression: remove the no-compression compressor/decompressor
Summary:
The no-compression decompressor cann't provide framing as other decompressors, so a safe approach would be not to have it at all.
I replaced occurances of no-compression with `Either` reader that seem to be a pattern present in the community (f.e. `futures::future::Either` or `itertools::Either`)

Reviewed By: jsgf

Differential Revision: D6555922

fbshipit-source-id: 998dafab8d9b2f00d058ce2f9e0aced76cf15b4e
2018-01-15 10:36:31 -08:00
Arun Kulshreshtha
fd2c414961 Update to Rust 1.21
Summary:
This diff does a few things:
  - Change the rust versions in `third-party{2,-buck}/config.py` to 1.21.
  - Update the tp2 symlinks for `rust` and `rust-crates-io`
  - Fix build breakages due to new errors/warnings from rustc.

Reviewed By: jsgf, Imxset21

Differential Revision: D6319954

fbshipit-source-id: cd4fe9e0d6f26c1a6c9c3f1256d84cb002bb83d6
2017-11-29 15:21:41 -08:00
Siddharth Agarwal
355e3e02ae futures-ext: add a version of the collect combinator that doesn't consume the stream
Summary:
Sometimes streams can have useful data hanging off of them. For example,
mercurial-bundles' `Bundle2Stream` communicates application-level errors via a
method on the struct. It's important to be able to access that data in tests.

Reviewed By: jsgf

Differential Revision: D6356907

fbshipit-source-id: 42cf2edd0a902e03a4acb894a3174c1c483cc6ab
2017-11-22 01:07:07 -08:00
Jeremy Fitzhardinge
6b5a13c1f6 rust: futures-ext: only consume as much input as needed for the decoder to make progress
Summary:
Avoid over-consuming the input, as excess input isn't easily pushed
back into the input stream. This is necessary to make sure that when parsing a
bundle2 stream we don't consume input from beyond the end of the stream, which
can upset the hg ssh command processor.

Reviewed By: sid0

Differential Revision: D6214174

fbshipit-source-id: 3a2227fab5ddfbb247437508206d40e85024c48e
2017-11-01 18:51:21 -07:00
Chris Konstad
93f8da21c9 Removed deprecated Tokio APIs from common/rust/futures-ext
Summary: See title

Reviewed By: sid0

Differential Revision: D5969152

fbshipit-source-id: e705e81d8ea07b8268267e238c4ebb310892f74e
2017-10-05 11:52:02 -07:00
Jeremy Fitzhardinge
64c19dcf5e rust: futures-ext: use ! for errors that can't happen
Summary:
We can use the "never_type" feature to enable more general use
of the `!` type, which indicates that the type state is impossible (ie,
`!` has no values). Not only is this more expressive than using - say -
`()`, it also allows irrefutable matching against a result (`let Ok(x)
= ...`), since the compiler knows that `Err(!)` can never happen.

Reviewed By: sid0

Differential Revision: D5849877

fbshipit-source-id: 48c14f9c2042fb8168eb1dd308fd3a79c9ed0fc2
2017-09-19 16:11:54 -07:00
Siddharth Agarwal
911164a107 add helpers to box up futures and streams
Summary:
This was deprecated upstream, but is still useful to us.

Also add `nonsend` versions since those are still required in a couple of
places.

Reviewed By: jsgf

Differential Revision: D5817016

fbshipit-source-id: 3753fadcae666099a96b3b849e438c5c16c7232f
2017-09-13 21:52:37 -07:00
Siddharth Agarwal
a74542da60 update and pull in uuid + subprocess
Summary:
Finally got an update working by removing the `mysql_async` crate.

Some notes:

* The `mysql_async` crate was responsible in this case: see https://github.com/rust-lang/cargo/issues/4066#issuecomment-328210204 for why.
* tokio/futures deprecated a bunch of stuff. I've filed a TODO for now.
* We finally pulled in error-chain 0.11, which has a bunch of nice improvements.

Reviewed By: kulshrax

Differential Revision: D5798282

fbshipit-source-id: a38a7b17ee0205428e2ea63334722aa408582493
2017-09-08 17:05:38 -07:00
facebook-github-bot
2b6af6b941 Initial commit
fbshipit-source-id: f75baa4ff6aa71973f677b752d7aba582cf4927f
2017-07-27 18:00:19 -07:00