# Flow is tied to the fdbclient

**URL:** <https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842>\
**Category:** FoundationDB Core\
**Created:** [November 4, 2018, 6:05pm UTC](https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842 "2018-11-04T18:05:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zzj1213](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/zzj1213/32/402_2.png) [@zzj1213](https://forums.foundationdb.org/u/zzj1213)\
**Post date:** [November 4, 2018, 6:05pm UTC](https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842/1 "2018-11-04T18:05:35Z")

</div>

```
		setupNetwork();
	Future<int> cliFuture = runCli(opt);
	Future<Void> timeoutFuture = opt.exit_timeout ? timeExit(opt.exit_timeout) : Never();
	auto f = stopNetworkAfter( success(cliFuture) || timeoutFuture );
	runNetwork();

```

the above code is from fdbcli.actor.cpp, setupNetwork() is tied to fdbclient/NativeAPI.h because of the IThreadPool. Any way to make Flow totally independent of fdb ?

---

<div class="post-metadata">

**Author:** ![alloc](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/alloc/32/9_2.png) [@alloc](https://forums.foundationdb.org/u/alloc)\
**Post date:** [November 4, 2018, 8:56pm UTC](https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842/2 "2018-11-04T20:56:52Z")

</div>

Even though the `setupNetwork` call is contained within the `fdbclient` directory, it isn’t doing too much that one couldn’t do oneself: [https://github.com/apple/foundationdb/blob/6bb1f4093d9b363a350831341230c6cb46e3c906/fdbclient/NativeAPI.actor.cpp#L868](https://github.com/apple/foundationdb/blob/6bb1f4093d9b363a350831341230c6cb46e3c906/fdbclient/NativeAPI.actor.cpp#L868)

I think a minimal FDB-less flow main method would look something like this:

```auto
ACTOR void runProgram();

ACTOR void setupMyProgram() {
    // Begin some futures, start some tasks, etc.
    // If your program is finite have it come back here
    // to end the run loop when done
    wait(runProgram());
    g_network->stop();
}

int main() {
    int randomSeed = platform::getRandomSeed();
    g_random = new DeterministicRandom(randomSeed);
    g_nondeterministic_random = new DeterministicRandom(platform::getRandomSeed());

    g_network = newNet2( NetworkAddress(), false );
    setupMyProgram();
    g_network->run();
}

```

(There may be a bug in there or two; I don’t write a lot of flow code, tbh.) The key here is setting the random number generators and then beginning the global network.

I think this should all be do-able depending on only the contents of the `flow` subdirectory, which is supposed to be the “FDB-less” flow. That being said, it contains some [data structures](https://github.com/apple/foundationdb/blob/master/flow/IndexedSet.h) that maybe more useful for FoundationDB than for the average project. The [error definitions](https://github.com/apple/foundationdb/blob/master/flow/error_definitions.h) also might seem suspiciously like they are more about the kinds of errors a distributed transactional database might encounter than the errors defined in most programming languages.

---

<div class="post-metadata">

**Author:** ![zzj1213](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/zzj1213/32/402_2.png) [@zzj1213](https://forums.foundationdb.org/u/zzj1213)\
**Post date:** [November 5, 2018, 11:31am UTC](https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842/3 "2018-11-05T11:31:30Z")

</div>

Thanks.

I will setup a Github repo for an independent Flow.

---

<div class="post-metadata">

**Author:** ![bowlofstew](https://avatars.discourse-cdn.com/v4/letter/b/aca169/32.png) [@bowlofstew](https://forums.foundationdb.org/u/bowlofstew)\
**Post date:** [November 5, 2018, 1:17pm UTC](https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842/4 "2018-11-05T13:17:02Z")

</div>

Dropbox’s initial Bazel PR also takes a stab at creating a flow library compilation for consumers:

> **[dropbox/foundationdb](https://github.com/dropbox/foundationdb/tree/pr/initial-bazel?files=1)**
>
> FoundationDB - the open source, distributed, transactional key-value store - dropbox/foundationdb

That being said, the above mentioned coupling would need cleaned up.

---

<div class="post-metadata">

**Author:** ![zzj1213](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/zzj1213/32/402_2.png) [@zzj1213](https://forums.foundationdb.org/u/zzj1213)\
**Post date:** [November 5, 2018, 4:11pm UTC](https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842/5 "2018-11-05T16:11:53Z")

</div>

> **[foundationflow/flow\_examples](https://github.com/foundationflow/flow_examples)**
>
> Examples to run the Foundation DB's Flow without dependency on FDB. - foundationflow/flow\_examples

This example is based on the **fdbcli** and the dependency on **fdbclient** is taken out. The current version still depends on _ **fdbclient/NativeAPI.h** _ .

---

<div class="post-metadata">

**Author:** ![zzj1213](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/zzj1213/32/402_2.png) [@zzj1213](https://forums.foundationdb.org/u/zzj1213)\
**Post date:** [November 6, 2018, 2:43pm UTC](https://forums.foundationdb.org/t/flow-is-tied-to-the-fdbclient/842/6 "2018-11-06T14:43:01Z")

</div>

> <https://github.com/foundationflow/flow_examples/blob/master/helloflow/helloflow.actor.cpp>

A very simple flow example (helloflow) without dependecy on FDB is here, not sure if doing thing right?
