Skip to content

Commit 3925a3c

Browse files
committed
BuckEvent: provide a Buck Event Publisher proto
Provide a BuckEvent Publisher service which emits BuckEvents to an external server implementation. Closes #226
1 parent 9528c3d commit 3925a3c

File tree

6 files changed

+106
-0
lines changed

6 files changed

+106
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ members = [
2828
"app/buck2_event_observer",
2929
"app/buck2_events",
3030
"app/buck2_event_log",
31+
"app/buck2_event_publisher_proto",
3132
"app/buck2_execute",
3233
"app/buck2_execute_impl",
3334
"app/buck2_external_cells",

app/buck2_event_publisher_proto/BUCK

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
load("@fbcode//buck2:proto_defs.bzl", "rust_protobuf_library")
2+
load("@fbsource//tools/build_defs:glob_defs.bzl", "glob")
3+
4+
oncall("build_infra")
5+
6+
rust_protobuf_library(
7+
name = "buck2_event_publisher_proto",
8+
srcs = glob(["src/**/*.rs"]),
9+
build_script = "build.rs",
10+
build_env = {
11+
"BUCK_HACK_DATA_PROTOC_INCLUDE": "$(location //buck2/app/buck2_data:data_proto)",
12+
},
13+
protos = ["event_publisher.proto"],
14+
deps = [
15+
"fbsource//third-party/rust:tonic",
16+
"//buck2/app/buck2_data:buck2_data",
17+
],
18+
)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "buck2_event_publisher_proto"
3+
4+
edition = "2021"
5+
license = { workspace = true }
6+
repository = { workspace = true }
7+
version = "0.1.0"
8+
9+
[dependencies]
10+
prost = { workspace = true }
11+
tonic = { workspace = true }
12+
13+
[build-dependencies]
14+
buck2_protoc_dev = { workspace = true }
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under both the MIT license found in the
5+
* LICENSE-MIT file in the root directory of this source tree and the Apache
6+
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
7+
* of this source tree.
8+
*/
9+
10+
use std::env;
11+
use std::io;
12+
use std::path::PathBuf;
13+
14+
fn main() -> io::Result<()> {
15+
let proto_files = &["event_publisher.proto"];
16+
17+
let data_include = if let Ok(value) = env::var("BUCK_HACK_DATA_PROTOC_INCLUDE") {
18+
let path = PathBuf::from(value);
19+
path.parent().unwrap().to_str().unwrap().to_owned()
20+
} else {
21+
"../buck2_data".to_owned()
22+
};
23+
24+
buck2_protoc_dev::configure()
25+
.setup_protoc()
26+
.extern_path(".buck.data", "::buck2_data")
27+
.compile(proto_files, &[".", &data_include])
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under both the MIT license found in the
5+
* LICENSE-MIT file in the root directory of this source tree and the Apache
6+
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
7+
* of this source tree.
8+
*/
9+
10+
syntax = "proto3";
11+
12+
import "data.proto";
13+
14+
package event_publisher;
15+
16+
message BuckEventRequest {
17+
// A trace-unique 64-bit identifying the stream.
18+
uint64 stream_id = 1;
19+
20+
buck.data.BuckEvent event = 2;
21+
};
22+
23+
message BuckEventResponse {
24+
// A trace-unique 64-bit identifying the stream.
25+
uint64 stream_id = 1;
26+
27+
// The trace ID of the event that has been committed.
28+
uint64 trace_id = 2;
29+
};
30+
31+
service BuckEventPublisher {
32+
rpc StreamBuckEvent(stream BuckEventRequest) returns (stream BuckEventResponse);
33+
};
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under both the MIT license found in the
5+
* LICENSE-MIT file in the root directory of this source tree and the Apache
6+
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
7+
* of this source tree.
8+
*/
9+
10+
#![feature(error_generic_member_access)]
11+
12+
tonic::include_proto!("event_publisher");

0 commit comments

Comments
 (0)