github.com/letsencrypt/trillian@v1.1.2-0.20180615153820-ae375a99d36a/util/proxy/logproxy.go (about)

     1  // Copyright 2017 Google Inc. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package proxy forwards Trillian Log Server requests to another server.
    16  package proxy
    17  
    18  import (
    19  	"context"
    20  
    21  	"github.com/google/trillian"
    22  )
    23  
    24  // Log implements the TrillianLogServer interface.
    25  //
    26  // For each RPC, Log forwards the request to the associated method in
    27  // the TrillianLogClient.
    28  type Log struct {
    29  	c trillian.TrillianLogClient
    30  }
    31  
    32  // NewLog returns a new proxy for the TrillianLogServer.
    33  func NewLog(c trillian.TrillianLogClient) *Log {
    34  	return &Log{c: c}
    35  }
    36  
    37  // QueueLeaf forwards the RPC.
    38  func (p *Log) QueueLeaf(ctx context.Context, in *trillian.QueueLeafRequest) (*trillian.QueueLeafResponse, error) {
    39  	return p.c.QueueLeaf(ctx, in)
    40  }
    41  
    42  // QueueLeaves forwards the RPC.
    43  func (p *Log) QueueLeaves(ctx context.Context, in *trillian.QueueLeavesRequest) (*trillian.QueueLeavesResponse, error) {
    44  	return p.c.QueueLeaves(ctx, in)
    45  }
    46  
    47  // AddSequencedLeaf forwards the RPC.
    48  func (p *Log) AddSequencedLeaf(ctx context.Context, in *trillian.AddSequencedLeafRequest) (*trillian.AddSequencedLeafResponse, error) {
    49  	return p.c.AddSequencedLeaf(ctx, in)
    50  }
    51  
    52  // AddSequencedLeaves forwards the RPC.
    53  func (p *Log) AddSequencedLeaves(ctx context.Context, in *trillian.AddSequencedLeavesRequest) (*trillian.AddSequencedLeavesResponse, error) {
    54  	return p.c.AddSequencedLeaves(ctx, in)
    55  }
    56  
    57  // GetInclusionProof forwards the RPC.
    58  func (p *Log) GetInclusionProof(ctx context.Context, in *trillian.GetInclusionProofRequest) (*trillian.GetInclusionProofResponse, error) {
    59  	return p.c.GetInclusionProof(ctx, in)
    60  }
    61  
    62  // GetInclusionProofByHash forwards the RPC.
    63  func (p *Log) GetInclusionProofByHash(ctx context.Context, in *trillian.GetInclusionProofByHashRequest) (*trillian.GetInclusionProofByHashResponse, error) {
    64  	return p.c.GetInclusionProofByHash(ctx, in)
    65  }
    66  
    67  // GetConsistencyProof forwards the RPC.
    68  func (p *Log) GetConsistencyProof(ctx context.Context, in *trillian.GetConsistencyProofRequest) (*trillian.GetConsistencyProofResponse, error) {
    69  	return p.c.GetConsistencyProof(ctx, in)
    70  }
    71  
    72  // GetLatestSignedLogRoot forwards the RPC.
    73  func (p *Log) GetLatestSignedLogRoot(ctx context.Context, in *trillian.GetLatestSignedLogRootRequest) (*trillian.GetLatestSignedLogRootResponse, error) {
    74  	return p.c.GetLatestSignedLogRoot(ctx, in)
    75  }
    76  
    77  // GetSequencedLeafCount forwards the RPC.
    78  func (p *Log) GetSequencedLeafCount(ctx context.Context, in *trillian.GetSequencedLeafCountRequest) (*trillian.GetSequencedLeafCountResponse, error) {
    79  	return p.c.GetSequencedLeafCount(ctx, in)
    80  }
    81  
    82  // GetLeavesByIndex forwards the RPC.
    83  func (p *Log) GetLeavesByIndex(ctx context.Context, in *trillian.GetLeavesByIndexRequest) (*trillian.GetLeavesByIndexResponse, error) {
    84  	return p.c.GetLeavesByIndex(ctx, in)
    85  }
    86  
    87  // GetLeavesByRange forwards the RPC.
    88  func (p *Log) GetLeavesByRange(ctx context.Context, in *trillian.GetLeavesByRangeRequest) (*trillian.GetLeavesByRangeResponse, error) {
    89  	return p.c.GetLeavesByRange(ctx, in)
    90  }
    91  
    92  // GetLeavesByHash forwards the RPC.
    93  func (p *Log) GetLeavesByHash(ctx context.Context, in *trillian.GetLeavesByHashRequest) (*trillian.GetLeavesByHashResponse, error) {
    94  	return p.c.GetLeavesByHash(ctx, in)
    95  }
    96  
    97  // GetEntryAndProof forwards the RPC.
    98  func (p *Log) GetEntryAndProof(ctx context.Context, in *trillian.GetEntryAndProofRequest) (*trillian.GetEntryAndProofResponse, error) {
    99  	return p.c.GetEntryAndProof(ctx, in)
   100  }