Skip to content
Permalink
Browse files

Rename RunBatch to ApplyRevisions (#1351)

This change removes the RunBatch API call, and introduces ApplyRevisions instead, with the same behavior.
  • Loading branch information...
pavelkalinnikov committed Aug 30, 2019
1 parent f17e989 commit 0249a5cf2408aabd3e814c5dd369995b38e6ca3f
@@ -244,8 +244,8 @@ func runSequencer(ctx context.Context, conn *grpc.ClientConn,
}
})
go sequencer.PeriodicallyRun(ctx, time.Tick(*refresh), func(ctx context.Context) {
if err := signer.RunBatchForAllMasterships(ctx); err != nil {
glog.Errorf("PeriodicallyRun(RunBatchForAllMasterships): %v", err)
if err := signer.ApplyRevisionsForAllMasterships(ctx); err != nil {
glog.Errorf("PeriodicallyRun(ApplyRevisionsForAllMasterships): %v", err)
}
})

@@ -84,9 +84,9 @@ func runBatchAndPublish(ctx context.Context, env *Env, mn, mx int32, block bool)
if _, err := env.Sequencer.DefineRevisions(ctx, drReq); err != nil {
return convert(err, "DefineRevisions()")
}
rbReq := &spb.RunBatchRequest{DirectoryId: env.Directory.DirectoryId}
if _, err := env.Sequencer.RunBatch(ctx, rbReq); err != nil {
return convert(err, "RunBatch()")
arReq := &spb.ApplyRevisionsRequest{DirectoryId: env.Directory.DirectoryId}
if _, err := env.Sequencer.ApplyRevisions(ctx, arReq); err != nil {
return convert(err, "ApplyRevisions()")
}
prReq := &spb.PublishRevisionsRequest{
DirectoryId: env.Directory.DirectoryId,
@@ -140,14 +140,15 @@ func (s *Sequencer) DefineRevisionsForAllMasterships(ctx context.Context, batchS
})
}

// RunBatchForAllMasterships runs KeyTransparencySequencerClient.RunBatch on
// all directories that this sequencer is currently master for.
func (s *Sequencer) RunBatchForAllMasterships(ctx context.Context) error {
glog.Infof("RunBatchForAllMasterships")
// ApplyRevisionsForAllMasterships runs KeyTransparencySequencerClient's
// ApplyRevisions method on all directories that this sequencer is currently
// master for.
func (s *Sequencer) ApplyRevisionsForAllMasterships(ctx context.Context) error {
glog.Infof("ApplyRevisionsForAllMasterships")
return s.ForAllMasterships(ctx, func(ctx context.Context, dirID string) error {
req := &spb.RunBatchRequest{DirectoryId: dirID}
if _, err := s.sequencerClient.RunBatch(ctx, req); err != nil {
glog.Errorf("RunBatch for %v failed: %v", dirID, err)
req := &spb.ApplyRevisionsRequest{DirectoryId: dirID}
if _, err := s.sequencerClient.ApplyRevisions(ctx, req); err != nil {
glog.Errorf("ApplyRevisions for %v failed: %v", dirID, err)
return err
}
return nil
@@ -44,15 +44,6 @@ message MapMetadata {
repeated SourceSlice sources = 2;
}

// RunBatchRequest triggers the sequencing of a batch of mutations for a
// directory, with the batch size governed by the request parameters.
message RunBatchRequest {
// directory_id is the directory to run for.
string directory_id = 1;
// Deprecated tags, do not reuse.
reserved 2, 3, 4;
}

// DefineRevisionsRequest contains information needed to define new revisions.
message DefineRevisionsRequest {
// directory_id is the directory to examine the outstanding mutations for.
@@ -94,6 +85,12 @@ message GetDefinedRevisionsResponse {
int64 highest_defined = 2;
}

// ApplyRevisionsRequest triggers applying revisions to the directory's map.
message ApplyRevisionsRequest {
// directory_id is the directory to apply revisions for.
string directory_id = 1;
}

// ApplyRevisionRequest contains information needed to create a new revision.
message ApplyRevisionRequest {
// directory_id is the directory to apply the mutations to.
@@ -137,14 +134,14 @@ message UpdateMetricsResponse {}

// The KeyTransparency Sequencer API.
service KeyTransparencySequencer {
// RunBatch figures out the outstanding revisions, and applies the
// corresponding mutations the to the map.
rpc RunBatch(RunBatchRequest) returns (google.protobuf.Empty);
// DefineRevisions returns the info on defined/applied revisions, after
// optionally defining a new revision of outstanding mutations.
rpc DefineRevisions(DefineRevisionsRequest) returns (DefineRevisionsResponse);
// GetDefinedRevisions returns the range of defined and unapplied revisions.
rpc GetDefinedRevisions(GetDefinedRevisionsRequest) returns (GetDefinedRevisionsResponse);
// ApplyRevisions figures out the outstanding revisions, and applies the
// corresponding mutations the to the map.
rpc ApplyRevisions(ApplyRevisionsRequest) returns (google.protobuf.Empty);
// ApplyRevision applies the contained mutations to the current map root.
// If this method fails, it must be retried with the same arguments.
rpc ApplyRevision(ApplyRevisionRequest) returns (ApplyRevisionResponse);

0 comments on commit 0249a5c

Please sign in to comment.
You can’t perform that action at this time.