sapling/eden/fs/service/TARGETS

224 lines
6.6 KiB
Plaintext
Raw Normal View History

# @noautodeps
include_defs("//eden/DEFS")
include_defs("//eden/fs/service/DEFS")
create_eden_fs_rules(
server_deps = [],
server_srcs = ["oss/RunServer.cpp"],
subdir = "out.oss",
suffix = get_oss_suffix(),
)
if is_facebook_internal():
include_defs('//eden/fs/service/facebook/DEFS')
create_eden_fs_rules(
suffix = get_fb_suffix(),
subdir = 'out.fb',
server_srcs = [
'facebook/RunServer.cpp',
],
server_deps = [
'//common/services/cpp:cpp',
],
)
cpp_library(
name = "server",
srcs = [
"EdenCPUThreadPool.cpp",
"EdenError.cpp",
"EdenServer.cpp",
"EdenServiceHandler.cpp",
"GlobNode.cpp",
"StreamingSubscriber.cpp",
],
headers = [
"EdenCPUThreadPool.h",
"EdenError.h",
"EdenServer.h",
"EdenServiceHandler.h",
"GlobNode.h",
"StreamingSubscriber.h",
],
undefined_symbols = True, # TODO(T23121628): fix deps and remove
deps = [
":thrift_cpp",
"//common/fb303/cpp:fb303",
"//eden/fs/config:config",
"//eden/fs/fuse:fusell",
"//eden/fs/fuse/privhelper:privhelper",
"//eden/fs/inodes:inodes",
"//eden/fs/store/git:git",
"//eden/fs/store/hg:hg",
"//eden/fs/takeover:takeover",
"//folly:conv",
"//folly:exception",
"//folly:exception_wrapper",
"//folly:executor",
"//folly:file",
"//folly:file_util",
"//folly:format",
"//folly:network_address",
"//folly:portability",
"//folly:range",
"//folly:stop_watch",
"//folly:string",
"//folly:synchronized",
"//folly:thread_local",
"//folly/container:access",
"//folly/experimental:string_keyed_map",
"//folly/experimental/logging:init",
"//folly/experimental/logging:logging",
"//folly/init:init",
"//thrift/lib/cpp/concurrency:thread_manager",
"//thrift/lib/cpp2:server",
],
)
# The eden.thrift interface.
#
# Note: C++ users should probably depend on the thrift_cpp rule below,
# rather than directly depending on this thrift_library(). The thrift_cpp rule
# includes this thrift_library() plus some extra utility code for working with
# the thrift C++ data structures.
thrift_library(
name = "thrift",
languages = [
"javadeprecated",
"py",
"rust",
],
py_base_module = "facebook",
thrift_args = ["--strict"],
thrift_srcs = {
"eden.thrift": ["EdenService"],
},
deps = [
"//common/fb303/if:fb303",
],
)
# This includes EdenService that is also present in the :thrift
# target defined in this file. Ideally we'd simply depend upon
# :thrift and just define StreamingEdenService here as a separate
# target, but Buck has problems locating the eden_types.h header
# during compilation. Instead we need to duplicate EdenService
# here and add StreamingEdenService alongside it. The result
# of this is that we cannot then include cpp2 in the languages
# selection for :thrift because Buck complains about the header
# mapping being ambiguous (the headers are present in both of
# these thrift_library targets).
additional query API for our thrift interface Summary: This diff adds a couple more things to our thrift interface: 1. Introduces JournalPosition 2. Adds methods to query the current JournalPosition and obtain a delta since a given JournalPosition 3. Augments getMaterializedFiles to also return the current JournalPosition 4. Adds a method to evaluate a `glob` against Eden 5. Adds a method using thrift streaming to subscribe to realtime changes Could probably finesse the naming a little bit. The JournalPosition allows reasoning about changes to files that are not part of an Eden snapshot. Internally the journal position is just the SequenceNumber from the journal datastructures, but when we expose it to clients we need to be able to distinguish between a sequence number from the current instance of the eden service and a prior incarnation (eg: if the process has been restarted, and we have no way to recreate the journal we need to be able to indicate this to the client if they ask about changes in that range). For the convenience of the client we also include the `toHash` (the most recent hash from the journal entry) which is likely useful for the `hg` dirstate operations; it is useful to know that the snapshot may have changed since the last query about the dirstate. The `getFileInformation` method returns the instantaneously available `stat()` like information about the requested list of files. Since we simply don't have historical data on how files in the overlay looked (only how they look now), this method does not allow passing in a JournalPosition. When it comes to comparing historical data, we will need to add an API that accepts two snapshot hashes and generates the results from there. This particular method is geared up to understanding the current state of the world; the obvious use case is plugging in the file list from `getFilesChangedSince` into this function to figure out what's what. * Do we want a function that combines `getFilesChangedSince` + `getFileInformation` into a single RPC? Why is there a glob method? It's to support a use-case in the watchman/buck integration. I'm just sketching it out in the thrift interface at this stage. In the future we also need to be able to express how to carry out a tree walk, but that will require some query predicates that I don't want to get hung up on specifying immediately. Why is the streaming stuff in its own thrift file? We can't generate code for it in java or perhaps also python. It's only needed to plumb data into watchman so it's broken out into its own definition. Nothing depends on that file yet, so it's probably not specified quite right. The important thing is how the subscribe method looks: it's essentially the same as the method to query a delta, but it keeps emitting deltas as they are produced. This is another API that will benefit from query predicates when we get around to specifying them. I've added `JournalDelta::fromHash` and `JournalDelta::toHash` to hold the appropriate snapshot ids in the journal entry; this will allow us to indicate when we've checked out a new snapshot, or created a new snapshot. We have no way to populate these yet; I commented on D3762646 about storing the `snapshotID` that we have during `EdenServiceHandler::mountImpl` into either the `EdenMount` or the proposed `RootInode` class. Once we have that we can simply sample it and store it as we generate `JournalDelta`s. Reviewed By: simpkins Differential Revision: D3860804 fbshipit-source-id: 896c24c354e6f58328fb45c24b16915d9e937108
2016-09-19 22:48:12 +03:00
thrift_library(
name = "thrift-streaming",
languages = ["cpp2"],
thrift_args = ["--strict"],
thrift_cpp2_options = "py_generator",
thrift_srcs = {
"streamingeden.thrift": [
"StreamingEdenService",
],
"eden.thrift": [
"EdenService",
],
},
deps = [
"//common/fb303/if:fb303",
],
additional query API for our thrift interface Summary: This diff adds a couple more things to our thrift interface: 1. Introduces JournalPosition 2. Adds methods to query the current JournalPosition and obtain a delta since a given JournalPosition 3. Augments getMaterializedFiles to also return the current JournalPosition 4. Adds a method to evaluate a `glob` against Eden 5. Adds a method using thrift streaming to subscribe to realtime changes Could probably finesse the naming a little bit. The JournalPosition allows reasoning about changes to files that are not part of an Eden snapshot. Internally the journal position is just the SequenceNumber from the journal datastructures, but when we expose it to clients we need to be able to distinguish between a sequence number from the current instance of the eden service and a prior incarnation (eg: if the process has been restarted, and we have no way to recreate the journal we need to be able to indicate this to the client if they ask about changes in that range). For the convenience of the client we also include the `toHash` (the most recent hash from the journal entry) which is likely useful for the `hg` dirstate operations; it is useful to know that the snapshot may have changed since the last query about the dirstate. The `getFileInformation` method returns the instantaneously available `stat()` like information about the requested list of files. Since we simply don't have historical data on how files in the overlay looked (only how they look now), this method does not allow passing in a JournalPosition. When it comes to comparing historical data, we will need to add an API that accepts two snapshot hashes and generates the results from there. This particular method is geared up to understanding the current state of the world; the obvious use case is plugging in the file list from `getFilesChangedSince` into this function to figure out what's what. * Do we want a function that combines `getFilesChangedSince` + `getFileInformation` into a single RPC? Why is there a glob method? It's to support a use-case in the watchman/buck integration. I'm just sketching it out in the thrift interface at this stage. In the future we also need to be able to express how to carry out a tree walk, but that will require some query predicates that I don't want to get hung up on specifying immediately. Why is the streaming stuff in its own thrift file? We can't generate code for it in java or perhaps also python. It's only needed to plumb data into watchman so it's broken out into its own definition. Nothing depends on that file yet, so it's probably not specified quite right. The important thing is how the subscribe method looks: it's essentially the same as the method to query a delta, but it keeps emitting deltas as they are produced. This is another API that will benefit from query predicates when we get around to specifying them. I've added `JournalDelta::fromHash` and `JournalDelta::toHash` to hold the appropriate snapshot ids in the journal entry; this will allow us to indicate when we've checked out a new snapshot, or created a new snapshot. We have no way to populate these yet; I commented on D3762646 about storing the `snapshotID` that we have during `EdenServiceHandler::mountImpl` into either the `EdenMount` or the proposed `RootInode` class. Once we have that we can simply sample it and store it as we generate `JournalDelta`s. Reviewed By: simpkins Differential Revision: D3860804 fbshipit-source-id: 896c24c354e6f58328fb45c24b16915d9e937108
2016-09-19 22:48:12 +03:00
)
# A helper library for C++ that depends on the generated thrift stubs,
# and includes a few other utilities for working with the thrift types.
#
# Most C++ users should depend on this rule rather than directly using the
# thrift or thrift-streaming rules above.
cpp_library(
name = "thrift_cpp",
srcs = [
"PrettyPrinters.cpp",
],
headers = [
"PrettyPrinters.h",
"ThriftUtil.h",
],
deps = [
":thrift-streaming-cpp2",
"//folly:optional",
"//folly:range",
],
)
python_library(
name = "py-client",
srcs = [
"__init__.py",
"client.py",
],
base_module = "eden.thrift",
deps = [
":thrift-py",
],
)
# JAVA BINDINGS FOR THRIFT ENDPOINT
#
# There are two JAR files that we expect Java clients to use:
# 1. A JAR that defines Eden's Thrift API.
# 2. A JAR that contains the general Java library for Thrift.
#
# For 1, when eden.thrift changes:
#
# buck build \
# --config java.target_level=7 \
# --config java.source_level=7 \
# //eden/fs/service:thrift-java
#
# Copy the resulting JAR
# (`buck targets --show-output //eden/fs/service:thrift-java`) to the project
# where you are using Eden in Java. (Note that the Java 7 config options are
# specified because Buck itself is currently limited to Java 7.)
#
# For 2, you should only have to build this once:
#
# buck build \
# --config java.target_level=7 \
# --config java.source_level=7 \
# //eden/fs/service:java-thrift-dependencies
#
# Copy the resulting JAR
# (`buck targets --show-output //eden/fs/service:java-thrift-dependencies`) to
# any project where you are using Thrift in Java. In theory, if the Java
# bindings for Thrift change, you will have to rebuild this, but it's unclear
# whether that code sees much activity these days. To be safe, you could always
# update this JAR when you update the Eden JAR.
# This java_binary() exists as a simple way to get //thrift/lib/java/src:thrift
# and all of its transitive dependencies into one JAR file.
#
# TODO: This is disabled in the open source build for now just because we
# don't have java build rules working yet. We should re-enable it once
# we get java+thrift working in the open source build.
if is_facebook_internal():
java_binary(
name = 'java-thrift-dependencies',
# Currently, //thrift/lib/java/src:thrift pulls in org.slf4j,
# org.iq80.snappy, and org.apache.commons.lang. org.iq80.snappy is the only
# one we keep.
blacklist = [
# Thrift only needs this dependency if the generated Java code uses
# `HashCodeBuilder`, which we do not.
'org.apache.commons.lang',
# The primary consumer of this JAR is Buck. Buck already has its own copy
# of slf4j that should be compatible with the one we are pulling in as
# part of this build. We decide to strip it rather than jarjar it.
'org.slf4j',
],
deps = [
'//common/fb303/if:fb303-javadeprecated',
'//third-party-java/org.slf4j:slf4j-api',
'//thrift/lib/java:thrift',
],
)