about summary refs log tree commit diff
path: root/tvix/castore/protos/rpc_directory.proto
blob: 8d4c22828547956dd57d1a6cb4bbe5669c044756 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: MIT
// Copyright © 2022 The Tvix Authors
syntax = "proto3";

package tvix.castore.v1;

import "tvix/castore/protos/castore.proto";

option go_package = "code.tvl.fyi/tvix/castore/protos;castorev1";

service DirectoryService {
  // Get retrieves a stream of Directory messages, by using the lookup
  // parameters in GetDirectoryRequest.
  // Keep in mind multiple DirectoryNodes in different parts of the graph might
  // have the same digest if they have the same underlying contents,
  // so sending subsequent ones can be omitted.
  rpc Get(GetDirectoryRequest) returns (stream Directory);

  // Put uploads a graph of Directory messages.
  // Individual Directory messages need to be send in an order walking up
  // from the leaves to the root - a Directory message can only refer to
  // Directory messages previously sent in the same stream.
  // Keep in mind multiple DirectoryNodes in different parts of the graph might
  // have the same digest if they have the same underlying contents,
  // so sending subsequent ones can be omitted.
  // We might add a separate method, allowing to send partial graphs at a later
  // time, if requiring to send the full graph turns out to be a problem.
  rpc Put(stream Directory) returns (PutDirectoryResponse);
}

message GetDirectoryRequest {
  oneof by_what {
      // The blake3 hash of the (root) Directory message, serialized in
      // protobuf canonical form.
      // Keep in mind this can be a subtree of another root.
      bytes digest = 1;
  }

  // If set to true, recursively resolve all child Directory messages.
  // Directory messages SHOULD be streamed in a recursive breadth-first walk,
  // but other orders are also fine, as long as Directory messages are only
  // sent after they are referred to from previously sent Directory messages.
  bool recursive = 2;
}

message PutDirectoryResponse {
  bytes root_digest = 1;
}