FoundationDB

Flow is tied to the fdbclient


(John) #1
		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 ?


(Alec Grieser) #2

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

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

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 that maybe more useful for FoundationDB than for the average project. The error definitions 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.


(John) #3

Thanks.

I will setup a Github repo for an independent Flow.


(Stewart Henderson) #4

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

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


(John) #5

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


(John) #6

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