syntax = "proto3";

option go_package = "github.com/google/trillian/skylog/storage/gcp/gcppb";

package gcppb;

// BuildJob is a Merke tree building job. It instructs workers to build a
// subtree covering leaves of the [begin, end) range for the specified tree.
message BuildJob {
  // The tree ID to build a subtree of.
  int64 tree_id = 1;
  // The beginning of the leaves range (inclusive).
  uint64 begin = 2;
  // The ending of the leaves range (exclusive).
  uint64 end = 3;

  // The tree sharding scheme that the build worker should use. Since builders
  // are stateless it is more efficient to pass it in from the master rather
  // than fetch it from storage on each job invocation.
  TreeSharding tree_sharding = 4;
  // The sequence sharding scheme that the build worker should use. It is
  // provided for the same reason as the tree sharding field.
  SequenceSharding seq_sharding = 5;
}

// TreeSharding describes the tree nodes sharding scheme.
//
// The specified number of lower tree levels are split into the specified number
// of shards, where each shard stores a periodic sub-structure of perfect
// subtrees. There is one extra shard covering the upper tree levels.
//
// See the tree storage comments for more details.
message TreeSharding {
  uint32 levels = 1;
  uint32 shards = 2;
}

// SequenceSharding describes the sequenced log entries sharding scheme.
//
// The sequence is split into the specified number of shards, where each shard
// stores a periodic sub-sequence consisting of stripes of the specified size.
//
// See the sequence storage comments for more details.
message SequenceSharding {
  uint32 shards = 1;
  uint64 size = 2;
}
