Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mentions to RPC #20

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions cmd/gcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ var (
notAfterStart timestampFlag
notAfterLimit timestampFlag

httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).")
tlsCert = flag.String("tls_certificate", "", "Path to server TLS certificate.")
tlsKey = flag.String("tls_key", "", "Path to server TLS private key.")
metricsEndpoint = flag.String("metrics_endpoint", "", "Endpoint for serving metrics; if left empty, metrics will be visible on --http_endpoint.")
// TODO(phboneff): delete / rename
rpcDeadline = flag.Duration("rpc_deadline", time.Second*10, "Deadline for backend RPC requests.")
httpEndpoint = flag.String("http_endpoint", "localhost:6962", "Endpoint for HTTP (host:port).")
tlsCert = flag.String("tls_certificate", "", "Path to server TLS certificate.")
tlsKey = flag.String("tls_key", "", "Path to server TLS private key.")
metricsEndpoint = flag.String("metrics_endpoint", "", "Endpoint for serving metrics; if left empty, metrics will be visible on --http_endpoint.")
tesseraDeadline = flag.Duration("tessera_deadline", time.Second*10, "Deadline for Tessera requests.")
roger2hk marked this conversation as resolved.
Show resolved Hide resolved
maskInternalErrors = flag.Bool("mask_internal_errors", false, "Don't return error strings with Internal Server Error HTTP responses.")
tracing = flag.Bool("tracing", false, "If true opencensus Stackdriver tracing will be enabled. See https://opencensus.io/.")
tracingProjectID = flag.String("tracing_project_id", "", "project ID to pass to stackdriver. Can be empty for GCP, consult docs for other platforms.")
Expand Down Expand Up @@ -109,11 +108,10 @@ func main() {
corsHandler := cors.AllowAll().Handler(corsMux)
http.Handle("/", corsHandler)

// Register handlers for all the configured logs using the correct RPC
// client.
// Register handlers for all the configured logs.
opts := sctfe.InstanceOptions{
Validated: vCfg,
Deadline: *rpcDeadline,
Deadline: *tesseraDeadline,
MetricFactory: prometheus.MetricFactory{},
RequestLog: new(sctfe.DefaultRequestLog),
MaskInternalErrors: *maskInternalErrors,
Expand Down
9 changes: 4 additions & 5 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,8 @@ func (a AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}

// Many/most of the handlers forward the request on to the Log RPC server; impose a deadline
// on this onward request.
ctx, cancel := context.WithDeadline(logCtx, getRPCDeadlineTime(a.Info))
// impose a deadline on this onward request.
ctx, cancel := context.WithDeadline(logCtx, deadlineTime(a.Info))
defer cancel()

var err error
Expand Down Expand Up @@ -414,8 +413,8 @@ func getRoots(_ context.Context, li *logInfo, w http.ResponseWriter, _ *http.Req
return http.StatusOK, nil
}

// getRPCDeadlineTime calculates the future time an RPC should expire based on our config
func getRPCDeadlineTime(li *logInfo) time.Time {
// deadlineTime calculates the future time an RPC should expire based on our config
func deadlineTime(li *logInfo) time.Time {
return li.TimeSource.Now().Add(li.instanceOpts.Deadline)
}

Expand Down
4 changes: 2 additions & 2 deletions handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/trillian/monitoring"
"github.com/transparency-dev/trillian-tessera/ctonly"
"github.com/transparency-dev/static-ct/mockstorage"
"github.com/transparency-dev/static-ct/testdata"
"github.com/transparency-dev/trillian-tessera/ctonly"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -532,7 +532,7 @@ func (d dlMatcher) Matches(x interface{}) bool {

deadlineTime, ok := ctx.Deadline()
if !ok {
return false // we never make RPC calls without a deadline set
return false // we never make calls without a deadline set
}

return deadlineTime == fakeDeadlineTime
Expand Down
3 changes: 0 additions & 3 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ type InstanceOptions struct {
Deadline time.Duration
// MetricFactory allows creating metrics.
MetricFactory monitoring.MetricFactory
// ErrorMapper converts an error from an RPC request to an HTTP status, plus
// a boolean to indicate whether the conversion succeeded.
ErrorMapper func(error) (int, bool)
// RequestLog provides structured logging of CTFE requests.
RequestLog RequestLog
MaskInternalErrors bool
Expand Down
Loading