From 564db4e9d29297626d9c2210587e6ab4d211a76b Mon Sep 17 00:00:00 2001 From: Tolga Ceylan Date: Fri, 13 Jul 2018 17:35:00 -0700 Subject: [PATCH] fn: Status should expose if data was served from cache. (#1123) This is useful in scenarios where gRPC client might want to reliably observe/report the status latency metrics and remove any possible duplicates. If the status query was served from cache, then these latencies show last execution latency. --- api/agent/grpc/runner.pb.go | 91 +++++++++++++++++++---------------- api/agent/grpc/runner.proto | 1 + api/agent/pure_runner.go | 1 + api/agent/runner_client.go | 1 + api/runnerpool/runner_pool.go | 1 + 5 files changed, 54 insertions(+), 41 deletions(-) diff --git a/api/agent/grpc/runner.pb.go b/api/agent/grpc/runner.pb.go index fba58b216..40973d29b 100644 --- a/api/agent/grpc/runner.pb.go +++ b/api/agent/grpc/runner.pb.go @@ -584,6 +584,7 @@ type RunnerStatus struct { CreatedAt string `protobuf:"bytes,8,opt,name=createdAt" json:"createdAt,omitempty"` StartedAt string `protobuf:"bytes,9,opt,name=startedAt" json:"startedAt,omitempty"` CompletedAt string `protobuf:"bytes,10,opt,name=completedAt" json:"completedAt,omitempty"` + Cached bool `protobuf:"varint,11,opt,name=cached" json:"cached,omitempty"` } func (m *RunnerStatus) Reset() { *m = RunnerStatus{} } @@ -654,6 +655,13 @@ func (m *RunnerStatus) GetCompletedAt() string { return "" } +func (m *RunnerStatus) GetCached() bool { + if m != nil { + return m.Cached + } + return false +} + func init() { proto.RegisterType((*TryCall)(nil), "TryCall") proto.RegisterType((*DataFrame)(nil), "DataFrame") @@ -809,46 +817,47 @@ var _RunnerProtocol_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("runner.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 655 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xed, 0x8a, 0xd3, 0x40, - 0x14, 0x6d, 0xd2, 0x36, 0x4d, 0x6f, 0xb2, 0x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, 0xdb, 0xab, 0xdc, 0x00, 0x68, 0x00, 0xbe, 0x0d, 0xa6, 0x5a, 0x46, 0x1d, - 0x9b, 0x58, 0xc7, 0x26, 0x33, 0x93, 0x8c, 0x68, 0x46, 0xdf, 0xe9, 0xa8, 0x6b, 0xc9, 0x1b, 0xc0, - 0xb0, 0xca, 0x5c, 0xc9, 0xb2, 0x5e, 0xc9, 0xd6, 0x00, 0x1a, 0x42, 0x90, 0x89, 0xd5, 0x9a, 0xb3, - 0x92, 0xef, 0x59, 0xbe, 0x09, 0xc5, 0x53, 0xe8, 0x9f, 0xf3, 0x9c, 0x15, 0xfa, 0x52, 0x2d, 0xd0, - 0x09, 0xb4, 0xb5, 0x2c, 0x9d, 0x0a, 0xc6, 0xfe, 0x6e, 0xb9, 0xd2, 0x16, 0x36, 0x30, 0x1a, 0x56, - 0xde, 0xbb, 0x96, 0x86, 0xa4, 0xde, 0x0a, 0xa3, 0x98, 0x61, 0x8c, 0x62, 0x57, 0x82, 0x6e, 0xe3, - 0x5f, 0x0e, 0xf4, 0xb1, 0xfd, 0x63, 0x4c, 0xd5, 0x57, 0x10, 0x4a, 0xab, 0xfd, 0xcc, 0x0e, 0x56, - 0x95, 0x3f, 0x4e, 0x6e, 0x99, 0x92, 0xb6, 0x70, 0x20, 0x1b, 0x1e, 0xdd, 0xd9, 0x0e, 0x3d, 0x05, - 0x7f, 0x5e, 0x79, 0x62, 0x25, 0x35, 0x4e, 0x36, 0x8d, 0x4a, 0x5b, 0xb8, 0x3e, 0x50, 0xcf, 0xf6, - 0xd3, 0x85, 0xb0, 0x9c, 0x6d, 0x6a, 0x37, 0x09, 0xdd, 0x07, 0x8f, 0x64, 0x3a, 0xbf, 0x2e, 0xb7, - 0xb1, 0x8b, 0xab, 0xc8, 0xe0, 0x73, 0x92, 0xf3, 0xaa, 0xb6, 0x8f, 0xab, 0x08, 0x1d, 0x82, 0x9b, + // 665 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00,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0x00, 0x00, 0xff, + 0xff, 0x17, 0xde, 0x8c, 0x60, 0x57, 0x05, 0x00, 0x00, } diff --git a/api/agent/grpc/runner.proto b/api/agent/grpc/runner.proto index 027213b07..e884f8c40 100644 --- a/api/agent/grpc/runner.proto +++ b/api/agent/grpc/runner.proto @@ -72,6 +72,7 @@ message RunnerStatus { string createdAt = 8; // call latency details: initialization time string startedAt = 9; // call latency details: start time in container string completedAt = 10; // call latency details: end time + bool cached = 11; // true if status response was provided from cache } service RunnerProtocol { diff --git a/api/agent/pure_runner.go b/api/agent/pure_runner.go index 0be58c47d..f32c2bd2f 100644 --- a/api/agent/pure_runner.go +++ b/api/agent/pure_runner.go @@ -805,6 +805,7 @@ func (pr *pureRunner) handleStatusCall(ctx context.Context) (*runner.RunnerStatu pr.status.lock.Unlock() + cacheObj.Cached = true cacheObj.Active = atomic.LoadInt32(&pr.status.inflight) return &cacheObj, nil } diff --git a/api/agent/runner_client.go b/api/agent/runner_client.go index 801f9340b..b6a156297 100644 --- a/api/agent/runner_client.go +++ b/api/agent/runner_client.go @@ -118,6 +118,7 @@ func TranslateGRPCStatusToRunnerStatus(status *pb.RunnerStatus) *pool.RunnerStat return &pool.RunnerStatus{ ActiveRequestCount: status.Active, StatusFailed: status.Failed, + Cached: status.Cached, StatusId: status.Id, Details: status.Details, ErrorCode: status.ErrorCode, diff --git a/api/runnerpool/runner_pool.go b/api/runnerpool/runner_pool.go index c697315da..6605e8f34 100644 --- a/api/runnerpool/runner_pool.go +++ b/api/runnerpool/runner_pool.go @@ -36,6 +36,7 @@ type MTLSRunnerFactory func(addr, certCommonName string, pki *PKIData) (Runner, type RunnerStatus struct { ActiveRequestCount int32 // Number of active running requests on Runner StatusFailed bool // True if Status execution failed + Cached bool // True if Status was provided from cache StatusId string // Call ID for Status Details string // General/Debug Log information ErrorCode int32 // If StatusFailed, then error code is set