Commit Graph

371 Commits

Author SHA1 Message Date
Alex Hornby
da5dac311b rust: remove patch for async-compression
Summary: Upstream crate has landed my PR for zstd 1.4.9 support and made a release, so can remove this patch now.

Reviewed By: ikostia

Differential Revision: D28221163

fbshipit-source-id: b95a6bee4f0c8d11f495dc17b2737c9ac9142b36
2021-05-05 12:20:34 -07:00
Toan Mai
410f7c5c61 Imported a mysql_common patch to support FromRow for tuples up to arity 16 (#23)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/rust-shed/pull/23

Pull Request resolved: https://github.com/facebookincubator/resctl/pull/8081

Pull Request resolved: https://github.com/facebookexperimental/eden/pull/82

Imported a mysql_common patch to support FromRow for tuples upto arity 16
Context: https://fburl.com/zfnw7r86

Followed the guide: https://www.internalfb.com/intern/wiki/Rust-at-facebook/Managing_fbsource_third-party_with_Reindeer/#maintaining-local-change

Reviewed By: marcelogomez

Differential Revision: D28094262

fbshipit-source-id: fed48e3950e8a3ba3d7a15407522167e5ae41a98
2021-05-05 10:32:48 -07:00
Alex Hornby
394ff15823 mononoke: make phases take iterator get_public_raw
Summary: It was requesting a slice but always converted it to an Iterator anyway.  Receiving an iterator saves constructing a temporary Vec both here and later in the stack

Reviewed By: krallin

Differential Revision: D28127582

fbshipit-source-id: 625c1f17f1ded973f8b2aa13566928af0df83aec
2021-05-05 09:52:36 -07:00
Stanislau Hlebik
f4c799dffa mononoke: record how long saving the raw bundle took
Reviewed By: krallin

Differential Revision: D28215994

fbshipit-source-id: 5be23dd10eeb483cd17926cb064ecfe9f566cad4
2021-05-05 03:03:47 -07:00
Gus Wynn
cbbb45206b slog max_level_debug -> trace
Reviewed By: Imxset21

Differential Revision: D28097080

fbshipit-source-id: 7d417f8256922926cf379d9c2fb3249f6d2544ef
2021-05-03 10:30:21 -07:00
Thomas Orozco
9c7aa6aaf7 third-party/rust: remove patches for Tokio 0.2 & Hyper 0.2
Summary:
We used to carry patches for Tokio 0.2 to add support for disabling Tokio coop
(which was necessary to make Mononoke work with it), but this was upstreamed
in Tokio 1.x (as a different implementation), so that's no longer needed. Nobody
else besides Mononoke was using this.

For Hyper we used to carry a patch with a bugfix. This was also fixed in Tokio
1.x-compatible versions of Hyper. There are still users of hyper-02 in fbcode.
However, this is only used for servers and only when accepting websocket
connections, and those users are just using Hyper as a HTTP client.

Reviewed By: farnz

Differential Revision: D28091331

fbshipit-source-id: de13b2452b654be6f3fa829404385e80a85c4420
2021-04-29 08:07:45 -07:00
Thomas Orozco
ffed22260d third-party/rust: remove Gotham 0.2
Summary:
This used to be used by Mononoke, but we're now on Tokio 1.x and on
corresponding versions of Gotham so it's not needed anymore.

Reviewed By: farnz

Differential Revision: D28091091

fbshipit-source-id: a58bcb4ba52f3f5d2eeb77b68ee4055d80fbfce2
2021-04-29 08:07:45 -07:00
Aida Getoeva
54c4a17e16 mononoke: remove async on FbConstruct methods
Summary: The methods don't do anything async anymore, let's remove `async`.

Reviewed By: krallin

Differential Revision: D28026899

fbshipit-source-id: 571eb2a1ba499876042c6e89770c803ac731cfe3
2021-04-28 11:14:52 -07:00
Thomas Orozco
0f44a4f106 mononoke: update to tokio 1.x
Summary:
NOTE: there is one final pre-requisite here, which is that we should default all Mononoke binaries to `--use-mysql-client` because the other SQL client implementations will break once this lands. That said, this is probably the right time to start reviewing.

There's a lot going on here, but Tokio updates being what they are, it has to happen as just one diff (though I did try to minimize churn by modernizing a bunch of stuff in earlier diffs).

Here's a detailed list of what is going on:

- I had to add a number `cargo_toml_dir` for binaries in `eden/mononoke/TARGETS`, because we have to use 2 versions of Bytes concurrently at this time, and the two cannot co-exist in the same Cargo workspace.
- Lots of little Tokio changes:
  - Stream abstractions moving to `tokio-stream`
  - `tokio::time::delay_for` became `tokio::time::sleep`
  - `tokio::sync::Sender::send` became `tokio::sync::Sender::broadcast`
  - `tokio::sync::Semaphore::acquire` returns a `Result` now.
  - `tokio::runtime::Runtime::block_on` no longer takes a `&mut self` (just a `&self`).
  - `Notify` grew a few more methods with different semantics. We only use this in tests, I used what seemed logical given the use case.
- Runtime builders have changed quite a bit:
  - My `no_coop` patch is gone in Tokio 1.x, but it has a new `tokio::task::unconstrained` wrapper (also from me), which I included on  `MononokeApi::new`.
  - Tokio now detects your logical CPUs, not physical CPUs, so we no longer need to use `num_cpus::get()` to figure it out.
- Tokio 1.x now uses Bytes 1.x:
  - At the edges (i.e. streams returned to Hyper or emitted by RepoClient), we need to return Bytes 1.x. However, internally we still use Bytes 0.5 in some places (notably: Filestore).
  - In LFS, this means we make a copy. We used to do that a while ago anyway (in the other direction) and it was never a meaningful CPU cost, so I think this is fine.
  - In Mononoke Server it doesn't really matter because that still generates ... Bytes 0.1 anyway so there was a copy before from 0.1 to 0.5 and it's from 0.1 to 1.x.
  - In the very few places where we read stuff using Tokio from the outside world (historical import tools for LFS), we copy.
- tokio-tls changed a lot, they removed all the convenience methods around connecting. This resulted in updates to:
  - How we listen in Mononoke Server & LFS
  - How we connect in hgcli.
  - Note: all this stuff has test coverage.
- The child process API changed a little bit. We used to have a ChildWrapper around the hg sync job to make a Tokio 0.2.x child look more like a Tokio 1.x Child, so now we can just remove this.
- Hyper changed their Websocket upgrade mechanism (you now need the whole `Request` to upgrade, whereas before that you needed just the `Body`, so I changed up our code a little bit in Mononoke's HTTP acceptor to defer splitting up the `Request` into parts until after we know whether we plan to upgrade it.
- I removed the MySQL tests that didn't use mysql client, because we're leaving that behind and don't intend to support it on Tokio 1.x.

Reviewed By: mitrandir77

Differential Revision: D26669620

fbshipit-source-id: acb6aff92e7f70a7a43f32cf758f252f330e60c9
2021-04-28 07:36:31 -07:00
Alex Hornby
bc85aade21 rust: update to zstd to 0.7.0+zstd.1.4.9
Summary:
Update the zstd crates.

This also patches async-compression crate to point at my fork until upstream PR https://github.com/Nemo157/async-compression/pull/117 to update to zstd 1.4.9 can land.

Reviewed By: jsgf, dtolnay

Differential Revision: D27942174

fbshipit-source-id: 26e604d71417e6910a02ec27142c3a16ea516c2b
2021-04-22 14:34:06 -07:00
Alex Hornby
45f521ddde mononoke: enable default patch.crates-io for internal Cargo.tomls
Reviewed By: quark-zju

Differential Revision: D27915811

fbshipit-source-id: 3f830def66c1c5f0569925c42cc8335ee585e0e7
2021-04-22 10:59:42 -07:00
Thomas Orozco
8ef8706e6e mononoke: add a new session class for WarmBookmarksCache
Summary:
I'd like to be able to track the proportion of traffic coming to bookmarks from
warm bookmarks cache vs. from elsewhere. We don't have a great abstraction to
pass this via the CoreContext at this time, but the SessionClass seems like a
pretty good fit.

Indeed, since it's always available in the CoreContext, and can be freely
mutated without having to rebuild the whole session. Besides, it aligns pretty
well with the existing use cases we have for SessionClass, which is to give you
different level of service depending on who you are.

Reviewed By: StanislavGlebik

Differential Revision: D27938413

fbshipit-source-id: a9dcc5a10c8d1459ee9586324a727c668e2e4e40
2021-04-22 08:13:09 -07:00
Stanislau Hlebik
70e41864c0 mononoke: use get_public_raw in getbundle
Summary:
Instead of using get_public method which queries bookmarks let's call
get_public_raw instead, which just does a phases fetch from a local db.

See previous diff for more motivation

Reviewed By: krallin

Differential Revision: D27821547

fbshipit-source-id: a71c8c9ad283259e9be98e63c9c72428e35c6142
2021-04-20 10:17:29 -07:00
Stanislau Hlebik
6183cd68e4 mononoke: log how manynodes were requested in known call to perf counter
Summary:
We didn't log it to perf counters log, and that makes it hard to aggregate,
show distributions etc

Let's start doing that

Reviewed By: krallin

Differential Revision: D27856968

fbshipit-source-id: 82fbba70154ee011073f3122256bd296bbb938ae
2021-04-20 04:06:54 -07:00
Stanislau Hlebik
5c7ff35af8 mononoke: copy bonsai changeset from prod repo to backup repo if they don't match
Summary:
To prevent bonsai changeset divergence between prod and backup repo by copying
bonsais from prod repo directly during hg sync job push.

See more details about motivation in D27824210

Reviewed By: ikostia

Differential Revision: D27852341

fbshipit-source-id: 93e0b1891008858eb99d5e692e4dd60c2e23f446
2021-04-19 09:00:11 -07:00
Stanislau Hlebik
d93c5a3784 mononoke: add public phase warmer
Reviewed By: krallin

Differential Revision: D27821286

fbshipit-source-id: ece394a2f7f46a3b67d6074a615741c56dc7e3d8
2021-04-16 08:20:48 -07:00
Kostia Balytskyi
fc3908e9fa repo_client: log full gettreepack args to scuba in verbose mode
Summary:
This will allow us to have greater visibility into what's going on when there are production issues.

Note: for getpack, the params data model is `[MPath, [Node]]`. In practice there seems to always just be 1 node per mpath. However, to preserve the mapping, I log every mpath in a separate sample.

Reviewed By: ahornby

Differential Revision: D26690685

fbshipit-source-id: 36616256747b61390b0435467892daeff2b4dd07
2021-04-14 08:29:59 -07:00
Stanislau Hlebik
0450243694 mononoke: fix sql query for streaming changelog
Summary:
Previously this query failed because it tried to convert bytes to int, and our
mysql wrapper doesn't support that.
Let's cast it instead

Reviewed By: krallin

Differential Revision: D27736863

fbshipit-source-id: 66a7cb33c0f623614f292511e18eb62e31ea582f
2021-04-13 11:15:00 -07:00
Stanislau Hlebik
85469374e9 mononoke: add leases to x-repo-sync
Reviewed By: ikostia

Differential Revision: D27677897

fbshipit-source-id: e86220f23f5950130f2f4ead2743f9a9b86abed7
2021-04-12 12:08:34 -07:00
Stanislau Hlebik
1876314c01 mononoke: allow blocking too large known calls
Summary:
Previously we ran into an issue where client has sent us too large known
request, and we passed it all the way to the mysql.

Mysql slow log shows that we have quite a few slow queries
(https://fburl.com/scuba/mysql_slow_log/w0ugmc1i), so it might be that these
requests are still coming, but because of the problems in the logging (see
previous diff), we can't know it for sure.

In any case, adding a knob like that can be useful

Reviewed By: farnz

Differential Revision: D27650806

fbshipit-source-id: c4c82b7b5781a85c349abb4e5fa534b5e8f125a0
2021-04-08 10:12:26 -07:00
Stanislau Hlebik
9b02233ed2 mononoke: deduplicate known* methods code
Summary:
the code is almost the same, so it would be good to deduplicate it. The
duplication let to the annoying differences in logging - i.e. we logged how
many nodes were sent to us in `known` call but not in `knownnodes` call.

Reviewed By: farnz

Differential Revision: D27650583

fbshipit-source-id: 5e2e3be3b9fd66631364d23f34d241c27e370340
2021-04-08 09:37:49 -07:00
Harvey Hunt
7358178f4a mononoke: Remove external sync logic
Summary:
Now that the `hg_external_sync` jobs are gone we can delete the code
in Mononoke that behaves differently when a sync job connects.

Reviewed By: StanislavGlebik

Differential Revision: D27500506

fbshipit-source-id: 443fb54577833dbf44ece6ae90a5f25ffed38cd5
2021-04-08 09:17:11 -07:00
Aida Getoeva
1f0a3fb467 mononoke: log error if couldn't fetch repo lock status
Summary:
Currently if we failed to fetch the repo status we only see "Repo is marked as read-only: Failed to fetch repo lock status" error, which is not very informative. Example of the error in production: P385612782.

Let's log the error.

Reviewed By: krallin

Differential Revision: D27621996

fbshipit-source-id: 85d9f0fe39397759da1b51e197f9188761678715
2021-04-08 04:03:18 -07:00
Liubov Dmitrieva
781cd19f2d Add support for wantsunhydratedcommits in Mononke
Summary:
Add support for returning unhydrated draft commits if requested by the client using a config option 'wantsunhydratedcommits'

This is needed to support slow enabling it for some clients like OnDemand.

Reviewed By: StanislavGlebik

Differential Revision: D27621442

fbshipit-source-id: 672129c8bfcbcdb4cee3ba1b092dac16c0b1877d
2021-04-08 03:48:07 -07:00
Stanislau Hlebik
47eee63dc2 mononoke: log file size to the post push scribe logging
Summary:
We already log file count, but file sizes is another useful piece of
information.

I evaluated two options - either do as I did in this diff or just change ScribeToScuba
logging python script to query scs to get file sizes. I opted for option #1
mainly because scs doesn't have a method to query file sizes for many files at once, and
querying one by one might be too expensive. We can add a method like that, but
that's a bit of a bigger change that I'd like.

Reviewed By: andll

Differential Revision: D27620507

fbshipit-source-id: 2618e60845bc293535b190d4da85df5667a7ab60
2021-04-07 23:34:40 -07:00
Mark Juggurnauth-Thomas
94ea52cdd4 repo_client/mononoke_repo: remove dependency on blobrepo_factory
Summary:
This import is only used for the `ReadOnlyStorage` type, which is canonically
defined in `blobstore_factory`.

Reviewed By: krallin

Differential Revision: D27363466

fbshipit-source-id: 7cb1effcee6d39de92b471fecfde56724d24a6a4
2021-04-07 14:01:47 -07:00
Thomas Orozco
3f710ee216 mononoke/repo_client: spawn check_lock_repo
Summary:
This is ... a stopgap :( There is probably some slow polling happening in
unbundle_future, and this causes us to fail to use our connection in time in
check_lock_repo...

Reviewed By: ahornby, StanislavGlebik

Differential Revision: D27620728

fbshipit-source-id: b747011405328b60419a99f0e5dbbaf64d53196a
2021-04-07 08:37:28 -07:00
Thomas Orozco
c934b67e5b mononoke: remove all trivial usage of async-unit
Summary:
I'd like to just get rid of that library since it's one more place where we
specify the Tokio version and that's a little annoying with the Tokio 1.x
update. Besides, this library is largely obsoleted by `#[fbinit::test]` and
`#[tokio::test]`.

Reviewed By: farnz

Differential Revision: D27619147

fbshipit-source-id: 4a316b81d882ea83c43bed05e873cabd2100b758
2021-04-07 07:26:57 -07:00
Stanislau Hlebik
a58b18a974 mononoke: verify bonsai changesets during replay
Differential Revision: D27362903

fbshipit-source-id: 136207fbab3f729e8575d8d06596ce790c3f4783
2021-03-29 12:39:19 -07:00
Mark Juggurnauth-Thomas
d156b6cada repo_client: remove dangerous_override
Summary:
Remove use of dangerous_override from the repo client tests.

Previously this was used to override filestore config, so just use the existing
config override mechanism to set the filestore params this is generated from.

Reviewed By: ahornby

Differential Revision: D27169424

fbshipit-source-id: 7d17437f0e218d1cf19cc64d48e1efdd7012e927
2021-03-25 10:46:07 -07:00
Mark Juggurnauth-Thomas
fb9f966acf test_repo_factory: use test factory for repo_client and repo_import tests
Summary: Use the test factory for existing repo_client and repo_import tests.

Reviewed By: StanislavGlebik

Differential Revision: D27169425

fbshipit-source-id: 2d0c34f129447232cec8faee42056d83613de179
2021-03-25 07:34:50 -07:00
Stanislau Hlebik
78c1530354 mononoke: add a tunable to limit the number of commits in a push
Summary:
While Mononoke should support pushing large commits, it's not clear if we need
(or want) to support pushing a lot of commits. At the very least pushing lots of commits at the same
time can create problems with derivation, but there could be more places that might break.
Besides there's usually an easy way to work around that i.e. sqush commits or push in small batches.
If we ever need to import a lot of it we use tools like blobimport/repo_import,
so blocking pushing of lots of commits should be fine.

Reviewed By: farnz

Differential Revision: D27237798

fbshipit-source-id: 435e61110f145b06a177d6e492905fccd38d83da
2021-03-22 15:41:06 -07:00
Mark Juggurnauth-Thomas
db324150a1 blobrepo: make attributes real members again
Summary:
In preparation for making `BlobRepo` buildable by facet factories, restore
`BlobRepo` members that had been converted to `TypeMap` attributes back into
real members.

This re-introduces some dependencies that were previously removed, but this
will be cleaned up when crates no longer have to depend on BlobRepo directly,
just the traits they are interested in.

Reviewed By: ahornby

Differential Revision: D27169422

fbshipit-source-id: 14354e6d984dfdd2be5c169f527e5f998f00db1e
2021-03-22 07:26:47 -07:00
Stanislau Hlebik
847a91291b mononoke: make it possible to allow moving a bookmark for a hipster group
Summary:
Currently we can only limit which users are allowed to move a bookmark by a
regex. We also want to allow specifying a hipster group.

Reviewed By: krallin

Differential Revision: D27156690

fbshipit-source-id: 99a5678a82f4c34ed2e57625361ba7cdb08ed839
2021-03-18 13:05:11 -07:00
Katie Mancini
8decc4733f Update reclone instructions to include fbclone --reclone
Summary:
the reclone option code has landed for fbclone, so now we can direct
users there first, so they don't have to go through all these steps

(won't land until I check that this option has actually made it to production)

I also updated the wiki this points to tell users to use `eden list` to detect
EdenFs checkouts instead of looking for .eden, as these steps are also for when
an EdenFS checkout is borked and needs a reclone and `eden list` more reliably
works in this situation.

Reviewed By: StanislavGlebik

Differential Revision: D26435380

fbshipit-source-id: 9153e730e1be949d130af85d604623d2bfbd3990
2021-03-17 19:10:24 -07:00
Stanislau Hlebik
fb4c1544b9 mononoke: add update command to streaming changelog
Summary:
This command can be used to update already existing streaming changelog.
It takes a newly cloned changelog and updates the new streaming changelog
chunks in the database.

The biggest difference from "create" command is that we first need to figure
out what's already uploaded to streaming changelog. For that two new methods
were added SqlStreamingChunksFetcher.

Reviewed By: farnz

Differential Revision: D27045386

fbshipit-source-id: 36fc9387f621e1ec8ad3eb4fbb767ab431a9d0bb
2021-03-16 03:29:54 -07:00
Stanislau Hlebik
480a0e9ef7 mononoke: start moving streaming changelog logic to rust
Summary:
Our current straming changelog updater logic is written in python, and it has a
few downsides:
1) It writes directly to manifold, which means it bypasses all the multiplexed
blobstore logic...
2) ...more importantly, we can't write to non-manifold blobstores at all.
3) There are no tests for the streaming changelogs

This diff moves the logic of initial creation of streaming changelog entry to
rust, which should fix the issues mentioned above. I want to highligh that
this implementation only works for the initial creation case i.e. when there are no
entries in the database. Next diffs will add incremental updates functionality.

Reviewed By: krallin

Differential Revision: D27008485

fbshipit-source-id: d9583bb1b98e5c4abea11c0a43c42bc673f8ed48
2021-03-12 14:46:30 -08:00
Stanislau Hlebik
f7e3a55184 mononoke: allow using streaming clone with sqlite
Summary:
Previously it was possible to use streaming clone only with xdb table. This
diff changes it

Reviewed By: farnz

Differential Revision: D27008486

fbshipit-source-id: b8d51832dd62b4343b36c3a7a96b83a327056025
2021-03-12 06:44:00 -08:00
Stanislau Hlebik
55dc8bf7d6 mononoke: remove unused getbundle_low_gen_num_threshold
Summary:
This tunable is not used anymore, we use
getbundle_high_low_gen_num_difference_threshold instead. Let's remove it.

Differential Revision: D26984966

fbshipit-source-id: 4e8ded5982f7e90c90476ff758b766df55644273
2021-03-12 03:14:51 -08:00
Mark Juggurnauth-Thomas
7ed5a54640 repo_client: remove case conflict checks on upload
Summary:
Remove case conflict checking on upload.  Disallowing case conflicts will
always be done during bookmark movement by checking the skeleton manifests.

A side-effect of this change is that configuring a repository with case
conflict checks, but not enabling skeleton manifests, will mean that commits
can't be landed in that repository, as there are no skeleton manifests to
check.

Reviewed By: ahornby

Differential Revision: D26781269

fbshipit-source-id: b4030bea5d92fa87f182a70d31f7e9d9e74989a9
2021-03-10 03:51:42 -08:00
Stanislau Hlebik
00883f94d2 mononoke: remove unused getbundle code
Summary:
It was added for the initial rollout only so that we can fallback quickly if
needed (see D26221250 (7115cf31d2)). We can remove it now since the feature has been enabled
for a few weeks already with no big issues.

Reviewed By: krallin

Differential Revision: D26909490

fbshipit-source-id: 849fac4838c272e92a04a971869842156e88a1cf
2021-03-09 04:12:09 -08:00
Stanislau Hlebik
d01927844e mononoke: add additional getbundle logging
Summary:
I've been investigating getbundle on mononoke darkstorm, and it was hard to
understand what's going on. Adding more logs hopefully should be easier.

Also fix how we log `nodes_to_send` - previously `partial_result.partial`
wasn't counted. Now it should be fixed.

Reviewed By: krallin

Differential Revision: D26909296

fbshipit-source-id: 0af6f0b8d6af0350b5c87a20146ef8c7c64b3dc8
2021-03-09 03:20:10 -08:00
Stanislau Hlebik
b5de3e4e21 mononoke: limit the number of hg blobs
Summary:
We ran into an issue while uploading too many blobs at once to darkstorm repo.
We were able to workaround this issue by spawning less blobstore writes at
once.

It's still a bit unclear why this issue happens exactly, but I'd like to make
the number of concurrent uploaded blobs configurable so that we can tweak it if
necessary.

Differential Revision: D26883061

fbshipit-source-id: 57c0d6fc51548b3c7404ebd55b5e07deba9e0601
2021-03-08 05:46:45 -08:00
Andrey Chursin
0be8e8ce29 vfs: introduce AsyncVfs
Summary:
AsyncVfs provides async vfs interface.
It will be used in the native checkout instead of current use case that spawns blocking tokio tasks for VFS action

Reviewed By: quark-zju

Differential Revision: D26801250

fbshipit-source-id: bb26c4fc8acac82f4b55bb3f2f3964a6d0b64014
2021-03-05 21:47:51 -08:00
Thomas Orozco
2a803fc10d third-party/rust: update futures
Summary:
Those newer versions of Futures have compatibility improvements with Tokio,
notably:

- https://github.com/rust-lang/futures-rs/pull/2333
- https://github.com/rust-lang/futures-rs/pull/2358

Reviewed By: farnz

Differential Revision: D26778794

fbshipit-source-id: 5a9dc002083e5edfa5c614d8d2242e586a93fcf6
2021-03-04 06:42:55 -08:00
Alex Hornby
2ff9ad0fea rust: async sql queries macros
Summary:
Async the query macros.  This change also migrates most callsites, with a few more complicated ones handle as separate diffs, which temporarily use sql01::queries in this diff.

With this change the query string is computed lazily (async fn/blocks being lazy) so we're not holding the extra memory of query string as well as query params for quite as long.  This is of most interest for queries doing writes where the query string can be large when large values passed (e.g. Mononoke sqlblob blobstore )

Reviewed By: krallin

Differential Revision: D26586715

fbshipit-source-id: e299932457682b0678734f44bb4bfb0b966edeec
2021-03-04 01:52:41 -08:00
Thomas Orozco
ef7045e818 common/rust: use fbinit-tokio
Summary:
This diffs add a layer of indirection between fbinit and tokio, thus allowing
us to use fbinit with tokio 0.2 or tokio 1.x.

The way this works is that you specify the Tokio you want by adding it as an
extra dependency alongside `fbinit` in your `TARGETS` (before this, you had to
always include `tokio-02`).

If you use `fbinit-tokio`, then `#[fbinit::main]` and `#[fbinit::test]` get you
a Tokio 1.x runtime, whereas if you use `fbinit-tokio-02`, you get a Tokio 0.2
runtime.

This diff is big, because it needs to change all the TARGETS that reference
this in the same diff that introduces the mechanism. I also didn't produce it
by hand.

Instead, I scripted the transformation using this script: P242773846

I then ran it using:

```
{ hg grep -l "fbinit::test"; hg grep -l "fbinit::main"  } | \
  sort | \
  uniq | \
  xargs ~/codemod/codemod.py \
&&  yes | arc lint \
&& common/rust/cargo_from_buck/bin/autocargo
```

Finally, I grabbed the files returned by `hg grep`, then fed them to:

```
arc lint-rust --paths-from ~/files2 --apply-patches --take RUSTFIXDEPS
```

(I had to modify the file list a bit: notably I removed stuff from scripts/ because
some of that causes Buck to crash when running lint-rust, and I also had to add
fbcode/ as a prefix everywhere).

Reviewed By: mitrandir77

Differential Revision: D26754757

fbshipit-source-id: 326b1c4efc9a57ea89db9b1d390677bcd2ab985e
2021-03-03 04:09:15 -08:00
David Tolnay
92f96c6555 Format fbsource with rustfmt-2.0.0-rc.2
Reviewed By: zertosh

Differential Revision: D26711985

fbshipit-source-id: 68e6482d041846bc0215b0984c03ef5fed043ebc
2021-02-27 18:46:09 -08:00
Lukas Piatkowski
f317302b0f autocargo v1: reformating of oss-dependencies, workspace and patch sections and thrift files to match v2
Summary:
For dependencies V2 puts "version" as the first attribute of dependency or just after "package" if present.
Workspace section is after patch section in V2 and since V2 autoformats patch section then the third-party/rust/Cargo.toml manual entries had to be formatted manually since V1 takes it as it is.
The thrift files are to have "generated by autocargo" and not only "generated" on their first line. This diff also removes some previously generated thrift files that have been incorrectly left when the corresponding Cargo.toml was removed.

Reviewed By: ikostia

Differential Revision: D26618363

fbshipit-source-id: c45d296074f5b0319bba975f3cb0240119729c92
2021-02-25 15:10:56 -08:00
Thomas Orozco
d71fa2882c common/rust/futures_ext: update to tokio_shim
Summary:
Like it says in the title, this updates futures_ext to use tokio_shim, which
makes it compatible with Tokio 0.2 and 1.0.

There is one small difference in behavior here, which is that in Tokio 1.0,
sleep isn't Unpin anymore, so callers will need to call `boxed()` or use Tokio's `pin!` macro if they need
Unpin.

I do want to get as close to what upstream is doing in Tokio 1.0, so I think
it's good to keep that behavior.

Reviewed By: farnz

Differential Revision: D26610036

fbshipit-source-id: ff72275da55558fdf8fe3ad009d25cf84e108a5a
2021-02-25 02:11:30 -08:00