2022-03-28 18:12:51 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-01-11 14:39:10 +00:00
|
|
|
"google.golang.org/protobuf/types/known/durationpb"
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
2022-03-28 18:12:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type QueryOptions struct {
|
|
|
|
// NOTE: fields omitted from upstream if not necessary for compilation check
|
|
|
|
MinQueryIndex uint64
|
|
|
|
MaxQueryTime time.Duration
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q QueryOptions) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
|
|
|
// NOTE: body was omitted from upstream; we only need the signature to verify it compiles
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type RPCInfo interface {
|
|
|
|
// NOTE: methods omitted from upstream if not necessary for compilation check
|
|
|
|
}
|
|
|
|
|
|
|
|
type QueryBackend int
|
|
|
|
|
|
|
|
const (
|
|
|
|
QueryBackendBlocking QueryBackend = iota
|
|
|
|
QueryBackendStreaming
|
|
|
|
)
|
|
|
|
|
2023-01-11 14:39:10 +00:00
|
|
|
func DurationToProto(d time.Duration) *durationpb.Duration {
|
|
|
|
return durationpb.New(d)
|
2022-03-28 18:12:51 +00:00
|
|
|
}
|
|
|
|
|
2023-01-11 14:39:10 +00:00
|
|
|
func DurationFromProto(d *durationpb.Duration) time.Duration {
|
|
|
|
return d.AsDuration()
|
2022-03-28 18:12:51 +00:00
|
|
|
}
|
|
|
|
|
2023-01-11 14:39:10 +00:00
|
|
|
func TimeFromProto(s *timestamppb.Timestamp) time.Time {
|
|
|
|
return s.AsTime()
|
2022-03-28 18:12:51 +00:00
|
|
|
}
|
|
|
|
|
2023-01-11 14:39:10 +00:00
|
|
|
func TimeToProto(s time.Time) *timestamppb.Timestamp {
|
|
|
|
return timestamppb.New(s)
|
2022-03-28 18:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsZeroProtoTime returns true if the time is the minimum protobuf timestamp
|
|
|
|
// (the Unix epoch).
|
2023-01-11 14:39:10 +00:00
|
|
|
func IsZeroProtoTime(t *timestamppb.Timestamp) bool {
|
2022-03-28 18:12:51 +00:00
|
|
|
return t.Seconds == 0 && t.Nanos == 0
|
|
|
|
}
|