Skip to content

Commit

Permalink
New thrift api for writing hashes
Browse files Browse the repository at this point in the history
Summary:
Adding a new method to write server's thrift API to support sending hashes (paths to batches) to be downloaded and written instead of sending batches themselves (the idea is described here: https://fb.workplace.com/groups/csi.eng/permalink/1994534877712244/)

As a first step I plan to only add an option to send hashes but leaving same mechanism synchronously waiting till write is complete (checking handle and passing "remember" flag on client side)

Reviewed By: simonmar

Differential Revision: D69524199

fbshipit-source-id: 3a57994c50e0fe29450611aca05969b2ce4e79fe
  • Loading branch information
iamirzhan authored and facebook-github-bot committed Feb 14, 2025
1 parent 9ed39fb commit 00dc2d1
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions glean/if/glean.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,34 @@ struct SendJsonBatchResponse {
1: Handle handle;
}

enum BatchFormat {
JSON = 0,
Binary = 1,
}

/// Batch information to get from the location and write to the db
struct BatchDescriptor {
1: string location;
2: BatchFormat format;
}

union EnqueueBatch {
1: BatchDescriptor descriptor;
}

enum EnqueueBatchWaitPolicy {
// The server will wait for the batch to be written before db complete.
None = 0,
// The server will remember the handle which can then be
// passed to finishBatch to check that the write has completed and
// obtain the substitution.
Remember = 1,
}

struct EnqueueBatchResponse {
1: Handle handle;
}

// How to fill a database
union KickOffFill {
// Use the recipe set with the given name
Expand Down Expand Up @@ -1147,6 +1175,13 @@ service GleanService extends fb303.FacebookService {
// Send a batch of fact. See the comments on ComputedBatch.
SendResponse sendBatch(1: ComputedBatch batch) throws (1: UnknownDatabase u);

// Enqueue batch of facts
EnqueueBatchResponse enqueueBatch(
1: Repo repo,
2: EnqueueBatch batch,
3: EnqueueBatchWaitPolicy waitPolicy,
) throws (1: Exception e, 2: Retry r, 3: UnknownDatabase u);

// Get the substitution for the given handle (obtained via a previous
// sendBatch) if no writes are outstanding for it. The server forgets the
// handle after this operation.
Expand Down
2 changes: 2 additions & 0 deletions glean/server/Glean/Handler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ handler State{..} req =

Service.SendBatch cbatch -> Backend.enqueueBatch backend cbatch

Service.EnqueueBatch {} -> error "not implemented"

Service.FinishBatch handle -> Backend.pollBatch backend handle

Service.SendJsonBatch repo batch ->
Expand Down

0 comments on commit 00dc2d1

Please sign in to comment.