mirror of https://github.com/status-im/consul.git
Remove the stdduration gogo extension
This commit is contained in:
parent
031e612bd8
commit
eea8300187
|
@ -1007,8 +1007,8 @@ func TestFallback(t *testing.T) {
|
|||
// waiting for events. We are going to send a new cert that is basically
|
||||
// already expired and then allow the fallback routine to kick in.
|
||||
secondCert := newLeaf(t, "autoconf", "dc1", testAC.initialRoots.Roots[0], 100, time.Nanosecond)
|
||||
secondCA := connect.TestCA(t, testAC.initialRoots.Roots[0])
|
||||
secondRoots := structs.IndexedCARoots{
|
||||
secondCA := caRootRoundtrip(t, connect.TestCA(t, testAC.initialRoots.Roots[0]))
|
||||
secondRoots := caRootsRoundtrip(t, &structs.IndexedCARoots{
|
||||
ActiveRootID: secondCA.ID,
|
||||
TrustDomain: connect.TestClusterID,
|
||||
Roots: []*structs.CARoot{
|
||||
|
@ -1018,7 +1018,7 @@ func TestFallback(t *testing.T) {
|
|||
QueryMeta: structs.QueryMeta{
|
||||
Index: 101,
|
||||
},
|
||||
}
|
||||
})
|
||||
thirdCert := newLeaf(t, "autoconf", "dc1", secondCA, 102, 10*time.Minute)
|
||||
|
||||
// setup the expectation for when the certs got updated initially
|
||||
|
@ -1063,7 +1063,7 @@ func TestFallback(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
resp.CARoots = mustTranslateCARootsToProtobuf(t, &secondRoots)
|
||||
resp.CARoots = mustTranslateCARootsToProtobuf(t, secondRoots)
|
||||
resp.Certificate = mustTranslateIssuedCertToProtobuf(t, thirdCert)
|
||||
resp.ExtraCACertificates = testAC.extraCerts
|
||||
|
||||
|
@ -1089,7 +1089,7 @@ func TestFallback(t *testing.T) {
|
|||
// auto-config response which is how the Fallback for auto-config works
|
||||
testAC.mcfg.tokens.On("UpdateAgentToken", testAC.originalToken, token.TokenSourceConfig).Return(true).Once()
|
||||
|
||||
testAC.mcfg.expectInitialTLS(t, "autoconf", "dc1", testAC.originalToken, secondCA, &secondRoots, thirdCert, testAC.extraCerts)
|
||||
testAC.mcfg.expectInitialTLS(t, "autoconf", "dc1", testAC.originalToken, secondCA, secondRoots, thirdCert, testAC.extraCerts)
|
||||
|
||||
// after the second RPC we now will use the new certs validity period in the next run loop iteration
|
||||
testAC.mcfg.tlsCfg.On("AutoEncryptCert").Return(&x509.Certificate{
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package autoconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
"github.com/hashicorp/consul/agent/config"
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/proto"
|
||||
"github.com/hashicorp/consul/proto/pbautoconf"
|
||||
"github.com/hashicorp/consul/proto/pbconfig"
|
||||
"github.com/hashicorp/consul/proto/pbconnect"
|
||||
|
@ -104,12 +99,12 @@ func stringPtrOrNil(v string) *string {
|
|||
}
|
||||
|
||||
func extractSignedResponse(resp *pbautoconf.AutoConfigResponse) (*structs.SignedResponse, error) {
|
||||
roots, err := translateCARootsToStructs(resp.CARoots)
|
||||
roots, err := pbconnect.CARootsToStructs(resp.CARoots)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cert, err := translateIssuedCertToStructs(resp.Certificate)
|
||||
cert, err := pbconnect.IssuedCertToStructs(resp.Certificate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -126,71 +121,3 @@ func extractSignedResponse(resp *pbautoconf.AutoConfigResponse) (*structs.Signed
|
|||
|
||||
return out, err
|
||||
}
|
||||
|
||||
// translateCARootsToStructs will create a structs.IndexedCARoots object from the corresponding
|
||||
// protobuf struct. Those structs are intended to be identical so the conversion just uses
|
||||
// mapstructure to go from one to the other.
|
||||
func translateCARootsToStructs(in *pbconnect.CARoots) (*structs.IndexedCARoots, error) {
|
||||
var out structs.IndexedCARoots
|
||||
if err := mapstructureTranslateToStructs(in, &out); err != nil {
|
||||
return nil, fmt.Errorf("Failed to re-encode CA Roots: %w", err)
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
// translateIssuedCertToStructs will create a structs.IssuedCert object from the corresponding
|
||||
// protobuf struct. Those structs are intended to be identical so the conversion just uses
|
||||
// mapstructure to go from one to the other.
|
||||
func translateIssuedCertToStructs(in *pbconnect.IssuedCert) (*structs.IssuedCert, error) {
|
||||
var out structs.IssuedCert
|
||||
if err := mapstructureTranslateToStructs(in, &out); err != nil {
|
||||
return nil, fmt.Errorf("Failed to re-encode CA Roots: %w", err)
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func mapstructureTranslateToStructs(in interface{}, out interface{}) error {
|
||||
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||
DecodeHook: proto.HookPBTimestampToTime,
|
||||
Result: out,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return decoder.Decode(in)
|
||||
}
|
||||
|
||||
func translateCARootsToProtobuf(in *structs.IndexedCARoots) (*pbconnect.CARoots, error) {
|
||||
var out pbconnect.CARoots
|
||||
if err := mapstructureTranslateToProtobuf(in, &out); err != nil {
|
||||
return nil, fmt.Errorf("Failed to re-encode CA Roots: %w", err)
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func translateIssuedCertToProtobuf(in *structs.IssuedCert) (*pbconnect.IssuedCert, error) {
|
||||
var out pbconnect.IssuedCert
|
||||
if err := mapstructureTranslateToProtobuf(in, &out); err != nil {
|
||||
return nil, fmt.Errorf("Failed to re-encode CA Roots: %w", err)
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func mapstructureTranslateToProtobuf(in interface{}, out interface{}) error {
|
||||
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||
DecodeHook: proto.HookTimeToPBTimestamp,
|
||||
Result: out,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return decoder.Decode(in)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package autoconf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -20,34 +19,26 @@ func boolPointer(b bool) *bool {
|
|||
return &b
|
||||
}
|
||||
|
||||
func translateCARootToProtobuf(in *structs.CARoot) (*pbconnect.CARoot, error) {
|
||||
var out pbconnect.CARoot
|
||||
if err := mapstructureTranslateToProtobuf(in, &out); err != nil {
|
||||
return nil, fmt.Errorf("Failed to re-encode CA Roots: %w", err)
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func mustTranslateCARootToProtobuf(t *testing.T, in *structs.CARoot) *pbconnect.CARoot {
|
||||
out, err := translateCARootToProtobuf(in)
|
||||
out, err := pbconnect.NewCARootFromStructs(in)
|
||||
require.NoError(t, err)
|
||||
return out
|
||||
}
|
||||
|
||||
func mustTranslateCARootsToStructs(t *testing.T, in *pbconnect.CARoots) *structs.IndexedCARoots {
|
||||
out, err := translateCARootsToStructs(in)
|
||||
out, err := pbconnect.CARootsToStructs(in)
|
||||
require.NoError(t, err)
|
||||
return out
|
||||
}
|
||||
|
||||
func mustTranslateCARootsToProtobuf(t *testing.T, in *structs.IndexedCARoots) *pbconnect.CARoots {
|
||||
out, err := translateCARootsToProtobuf(in)
|
||||
out, err := pbconnect.NewCARootsFromStructs(in)
|
||||
require.NoError(t, err)
|
||||
return out
|
||||
}
|
||||
|
||||
func mustTranslateIssuedCertToProtobuf(t *testing.T, in *structs.IssuedCert) *pbconnect.IssuedCert {
|
||||
out, err := translateIssuedCertToProtobuf(in)
|
||||
out, err := pbconnect.NewIssuedCertFromStructs(in)
|
||||
require.NoError(t, err)
|
||||
return out
|
||||
}
|
||||
|
@ -159,3 +150,26 @@ func TestCArootsTranslation(t *testing.T) {
|
|||
protoRoots := mustTranslateCARootsToProtobuf(t, indexedRoots)
|
||||
require.Equal(t, indexedRoots, mustTranslateCARootsToStructs(t, protoRoots))
|
||||
}
|
||||
|
||||
func caRootRoundtrip(t *testing.T, s *structs.CARoot) *structs.CARoot {
|
||||
pbRoot, err := pbconnect.NewCARootFromStructs(s)
|
||||
require.NoError(t, err)
|
||||
root, err := pbconnect.CARootToStructs(pbRoot)
|
||||
require.NoError(t, err)
|
||||
return root
|
||||
}
|
||||
func caRootsRoundtrip(t *testing.T, s *structs.IndexedCARoots) *structs.IndexedCARoots {
|
||||
pbRoot, err := pbconnect.NewCARootsFromStructs(s)
|
||||
require.NoError(t, err)
|
||||
root, err := pbconnect.CARootsToStructs(pbRoot)
|
||||
require.NoError(t, err)
|
||||
return root
|
||||
}
|
||||
|
||||
func issuedCertRoundtrip(t *testing.T, s *structs.IssuedCert) *structs.IssuedCert {
|
||||
pbCert, err := pbconnect.NewIssuedCertFromStructs(s)
|
||||
require.NoError(t, err)
|
||||
cert, err := pbconnect.IssuedCertToStructs(pbCert)
|
||||
require.NoError(t, err)
|
||||
return cert
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/hashicorp/consul/agent/connect"
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/proto/pbautoconf"
|
||||
"github.com/hashicorp/consul/proto/pbconnect"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -140,7 +141,7 @@ func (ac *AutoConfig) updateCARoots(roots *structs.IndexedCARoots) error {
|
|||
ac.Lock()
|
||||
defer ac.Unlock()
|
||||
var err error
|
||||
ac.autoConfigResponse.CARoots, err = translateCARootsToProtobuf(roots)
|
||||
ac.autoConfigResponse.CARoots, err = pbconnect.NewCARootsFromStructs(roots)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -167,7 +168,7 @@ func (ac *AutoConfig) updateLeafCert(cert *structs.IssuedCert) error {
|
|||
ac.Lock()
|
||||
defer ac.Unlock()
|
||||
var err error
|
||||
ac.autoConfigResponse.Certificate, err = translateIssuedCertToProtobuf(cert)
|
||||
ac.autoConfigResponse.Certificate, err = pbconnect.NewIssuedCertFromStructs(cert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func newLeaf(t *testing.T, agentName, datacenter string, ca *structs.CARoot, idx
|
|||
agentID, ok := spiffeID.(*connect.SpiffeIDAgent)
|
||||
require.True(t, ok, "certificate doesn't have an agent leaf cert URI")
|
||||
|
||||
return &structs.IssuedCert{
|
||||
return issuedCertRoundtrip(t, &structs.IssuedCert{
|
||||
SerialNumber: cert.SerialNumber.String(),
|
||||
CertPEM: pub,
|
||||
PrivateKeyPEM: priv,
|
||||
|
@ -36,21 +36,20 @@ func newLeaf(t *testing.T, agentName, datacenter string, ca *structs.CARoot, idx
|
|||
CreateIndex: idx,
|
||||
ModifyIndex: idx,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func testCerts(t *testing.T, agentName, datacenter string) (*structs.CARoot, *structs.IndexedCARoots, *structs.IssuedCert) {
|
||||
ca := connect.TestCA(t, nil)
|
||||
ca.IntermediateCerts = make([]string, 0)
|
||||
cert := newLeaf(t, agentName, datacenter, ca, 1, 10*time.Minute)
|
||||
indexedRoots := structs.IndexedCARoots{
|
||||
indexedRoots := caRootsRoundtrip(t, &structs.IndexedCARoots{
|
||||
ActiveRootID: ca.ID,
|
||||
TrustDomain: connect.TestClusterID,
|
||||
Roots: []*structs.CARoot{
|
||||
ca,
|
||||
},
|
||||
QueryMeta: structs.QueryMeta{Index: 1},
|
||||
}
|
||||
})
|
||||
|
||||
return ca, &indexedRoots, cert
|
||||
return ca, indexedRoots, cert
|
||||
}
|
||||
|
|
|
@ -7,10 +7,8 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/hashicorp/consul/acl"
|
||||
"github.com/hashicorp/consul/proto"
|
||||
|
||||
bexpr "github.com/hashicorp/go-bexpr"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
"github.com/hashicorp/consul/agent/connect"
|
||||
"github.com/hashicorp/consul/agent/consul/authmethod/ssoauth"
|
||||
|
@ -166,7 +164,7 @@ func (ac *AutoConfig) updateTLSCertificatesInConfig(opts AutoConfigOptions, resp
|
|||
}
|
||||
|
||||
// convert to the protobuf form of the issued certificate
|
||||
pbcert, err := translateIssuedCertToProtobuf(cert)
|
||||
pbcert, err := pbconnect.NewIssuedCertFromStructs(cert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -179,7 +177,7 @@ func (ac *AutoConfig) updateTLSCertificatesInConfig(opts AutoConfigOptions, resp
|
|||
}
|
||||
|
||||
// convert to the protobuf form of the issued certificate
|
||||
pbroots, err := translateCARootsToProtobuf(connectRoots)
|
||||
pbroots, err := pbconnect.NewCARootsFromStructs(connectRoots)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -403,37 +401,6 @@ func parseAutoConfigCSR(csr string) (*x509.CertificateRequest, *connect.SpiffeID
|
|||
return x509CSR, agentID, nil
|
||||
}
|
||||
|
||||
func translateCARootsToProtobuf(in *structs.IndexedCARoots) (*pbconnect.CARoots, error) {
|
||||
var out pbconnect.CARoots
|
||||
if err := mapstructureTranslateToProtobuf(in, &out); err != nil {
|
||||
return nil, fmt.Errorf("Failed to re-encode CA Roots: %w", err)
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func translateIssuedCertToProtobuf(in *structs.IssuedCert) (*pbconnect.IssuedCert, error) {
|
||||
var out pbconnect.IssuedCert
|
||||
if err := mapstructureTranslateToProtobuf(in, &out); err != nil {
|
||||
return nil, fmt.Errorf("Failed to re-encode CA Roots: %w", err)
|
||||
}
|
||||
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
func mapstructureTranslateToProtobuf(in interface{}, out interface{}) error {
|
||||
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||
DecodeHook: proto.HookTimeToPBTimestamp,
|
||||
Result: out,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return decoder.Decode(in)
|
||||
}
|
||||
|
||||
func printNodeName(nodeName, partition string) string {
|
||||
if structs.IsDefaultPartition(partition) {
|
||||
return nodeName
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/hashicorp/consul/internal/go-sso/oidcauth/oidcauthtest"
|
||||
"github.com/hashicorp/consul/proto/pbautoconf"
|
||||
"github.com/hashicorp/consul/proto/pbconfig"
|
||||
"github.com/hashicorp/consul/proto/pbconnect"
|
||||
"github.com/hashicorp/consul/sdk/testutil"
|
||||
"github.com/hashicorp/consul/tlsutil"
|
||||
|
||||
|
@ -199,7 +200,7 @@ func TestAutoConfigInitialConfiguration(t *testing.T) {
|
|||
roots, err := s.getCARoots(nil, s.fsm.State())
|
||||
require.NoError(t, err)
|
||||
|
||||
pbroots, err := translateCARootsToProtobuf(roots)
|
||||
pbroots, err := pbconnect.NewCARootsFromStructs(roots)
|
||||
require.NoError(t, err)
|
||||
|
||||
joinAddr := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: s.config.SerfLANConfig.MemberlistConfig.AdvertisePort}
|
||||
|
@ -595,7 +596,7 @@ func TestAutoConfig_updateTLSCertificatesInConfig(t *testing.T) {
|
|||
|
||||
// translate the fake cert to the protobuf equivalent
|
||||
// for embedding in expected results
|
||||
pbcert, err := translateIssuedCertToProtobuf(&fakeCert)
|
||||
pbcert, err := pbconnect.NewIssuedCertFromStructs(&fakeCert)
|
||||
require.NoError(t, err)
|
||||
|
||||
// generate a CA certificate to use for specifying non-Connect
|
||||
|
@ -613,7 +614,7 @@ func TestAutoConfig_updateTLSCertificatesInConfig(t *testing.T) {
|
|||
|
||||
// translate the roots response to protobuf to be embedded
|
||||
// into the expected results
|
||||
pbroots, err := translateCARootsToProtobuf(&roots)
|
||||
pbroots, err := pbconnect.NewCARootsFromStructs(&roots)
|
||||
require.NoError(t, err)
|
||||
|
||||
type testCase struct {
|
||||
|
|
|
@ -548,10 +548,18 @@ func (c *limitedConn) Read(b []byte) (n int, err error) {
|
|||
|
||||
// canRetry returns true if the request and error indicate that a retry is safe.
|
||||
func canRetry(info structs.RPCInfo, err error, start time.Time, config *Config) bool {
|
||||
if info != nil && info.HasTimedOut(start, config.RPCHoldTimeout, config.MaxQueryTime, config.DefaultQueryTime) {
|
||||
// RPCInfo timeout may include extra time for MaxQueryTime
|
||||
return false
|
||||
} else if info == nil && time.Since(start) > config.RPCHoldTimeout {
|
||||
if info != nil {
|
||||
timedOut, timeoutError := info.HasTimedOut(start, config.RPCHoldTimeout, config.MaxQueryTime, config.DefaultQueryTime)
|
||||
if timeoutError != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if timedOut {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if info == nil && time.Since(start) > config.RPCHoldTimeout {
|
||||
// When not RPCInfo, timeout is only RPCHoldTimeout
|
||||
return false
|
||||
}
|
||||
|
@ -920,7 +928,7 @@ type queryFn func(memdb.WatchSet, *state.Store) error
|
|||
type blockingQueryOptions interface {
|
||||
GetToken() string
|
||||
GetMinQueryIndex() uint64
|
||||
GetMaxQueryTime() time.Duration
|
||||
GetMaxQueryTime() (time.Duration, error)
|
||||
GetRequireConsistent() bool
|
||||
}
|
||||
|
||||
|
@ -1012,7 +1020,11 @@ func (s *Server) blockingQuery(
|
|||
return err
|
||||
}
|
||||
|
||||
timeout := s.rpcQueryTimeout(opts.GetMaxQueryTime())
|
||||
maxQueryTimeout, err := opts.GetMaxQueryTime()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
timeout := s.rpcQueryTimeout(maxQueryTimeout)
|
||||
ctx, cancel := context.WithTimeout(ctx, timeout)
|
||||
defer cancel()
|
||||
|
||||
|
|
|
@ -1366,8 +1366,8 @@ func (r isReadRequest) IsRead() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (r isReadRequest) HasTimedOut(since time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool {
|
||||
return false
|
||||
func (r isReadRequest) HasTimedOut(since time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func TestRPC_AuthorizeRaftRPC(t *testing.T) {
|
||||
|
|
|
@ -770,13 +770,18 @@ func setLastContact(resp http.ResponseWriter, last time.Duration) {
|
|||
}
|
||||
|
||||
// setMeta is used to set the query response meta data
|
||||
func setMeta(resp http.ResponseWriter, m structs.QueryMetaCompat) {
|
||||
func setMeta(resp http.ResponseWriter, m structs.QueryMetaCompat) error {
|
||||
lastContact, err := m.GetLastContact()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
setLastContact(resp, lastContact)
|
||||
setIndex(resp, m.GetIndex())
|
||||
setLastContact(resp, m.GetLastContact())
|
||||
setKnownLeader(resp, m.GetKnownLeader())
|
||||
setConsistency(resp, m.GetConsistencyLevel())
|
||||
setQueryBackend(resp, m.GetBackend())
|
||||
setResultsFilteredByACLs(resp, m.GetResultsFilteredByACLs())
|
||||
return nil
|
||||
}
|
||||
|
||||
func setQueryBackend(resp http.ResponseWriter, backend structs.QueryBackend) {
|
||||
|
|
|
@ -12,7 +12,7 @@ type QueryOptionsCompat interface {
|
|||
SetToken(string)
|
||||
GetMinQueryIndex() uint64
|
||||
SetMinQueryIndex(uint64)
|
||||
GetMaxQueryTime() time.Duration
|
||||
GetMaxQueryTime() (time.Duration, error)
|
||||
SetMaxQueryTime(time.Duration)
|
||||
GetAllowStale() bool
|
||||
SetAllowStale(bool)
|
||||
|
@ -20,13 +20,13 @@ type QueryOptionsCompat interface {
|
|||
SetRequireConsistent(bool)
|
||||
GetUseCache() bool
|
||||
SetUseCache(bool)
|
||||
GetMaxStaleDuration() time.Duration
|
||||
GetMaxStaleDuration() (time.Duration, error)
|
||||
SetMaxStaleDuration(time.Duration)
|
||||
GetMaxAge() time.Duration
|
||||
GetMaxAge() (time.Duration, error)
|
||||
SetMaxAge(time.Duration)
|
||||
GetMustRevalidate() bool
|
||||
SetMustRevalidate(bool)
|
||||
GetStaleIfError() time.Duration
|
||||
GetStaleIfError() (time.Duration, error)
|
||||
SetStaleIfError(time.Duration)
|
||||
GetFilter() string
|
||||
SetFilter(string)
|
||||
|
@ -36,7 +36,7 @@ type QueryOptionsCompat interface {
|
|||
// and the proto/pbcommon.QueryMeta structs need to implement so that they
|
||||
// can be operated on interchangeably
|
||||
type QueryMetaCompat interface {
|
||||
GetLastContact() time.Duration
|
||||
GetLastContact() (time.Duration, error)
|
||||
SetLastContact(time.Duration)
|
||||
GetKnownLeader() bool
|
||||
SetKnownLeader(bool)
|
||||
|
@ -69,11 +69,11 @@ func (m *QueryOptions) GetMinQueryIndex() uint64 {
|
|||
|
||||
// GetMaxQueryTime helps implement the QueryOptionsCompat interface
|
||||
// Copied from proto/pbcommon/common.pb.go
|
||||
func (m *QueryOptions) GetMaxQueryTime() time.Duration {
|
||||
func (m *QueryOptions) GetMaxQueryTime() (time.Duration, error) {
|
||||
if m != nil {
|
||||
return m.MaxQueryTime
|
||||
return m.MaxQueryTime, nil
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetAllowStale helps implement the QueryOptionsCompat interface
|
||||
|
@ -105,20 +105,20 @@ func (m *QueryOptions) GetUseCache() bool {
|
|||
|
||||
// GetMaxStaleDuration helps implement the QueryOptionsCompat interface
|
||||
// Copied from proto/pbcommon/common.pb.go
|
||||
func (m *QueryOptions) GetMaxStaleDuration() time.Duration {
|
||||
func (m *QueryOptions) GetMaxStaleDuration() (time.Duration, error) {
|
||||
if m != nil {
|
||||
return m.MaxStaleDuration
|
||||
return m.MaxStaleDuration, nil
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetMaxAge helps implement the QueryOptionsCompat interface
|
||||
// Copied from proto/pbcommon/common.pb.go
|
||||
func (m *QueryOptions) GetMaxAge() time.Duration {
|
||||
func (m *QueryOptions) GetMaxAge() (time.Duration, error) {
|
||||
if m != nil {
|
||||
return m.MaxAge
|
||||
return m.MaxAge, nil
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetMustRevalidate helps implement the QueryOptionsCompat interface
|
||||
|
@ -132,11 +132,11 @@ func (m *QueryOptions) GetMustRevalidate() bool {
|
|||
|
||||
// GetStaleIfError helps implement the QueryOptionsCompat interface
|
||||
// Copied from proto/pbcommon/common.pb.go
|
||||
func (m *QueryOptions) GetStaleIfError() time.Duration {
|
||||
func (m *QueryOptions) GetStaleIfError() (time.Duration, error) {
|
||||
if m != nil {
|
||||
return m.StaleIfError
|
||||
return m.StaleIfError, nil
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetFilter helps implement the QueryOptionsCompat interface
|
||||
|
@ -224,11 +224,11 @@ func (m *QueryMeta) GetIndex() uint64 {
|
|||
|
||||
// GetLastContact helps implement the QueryMetaCompat interface
|
||||
// Copied from proto/pbcommon/common.pb.go
|
||||
func (m *QueryMeta) GetLastContact() time.Duration {
|
||||
func (m *QueryMeta) GetLastContact() (time.Duration, error) {
|
||||
if m != nil {
|
||||
return m.LastContact
|
||||
return m.LastContact, nil
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetKnownLeader helps implement the QueryMetaCompat interface
|
||||
|
|
|
@ -209,7 +209,7 @@ type RPCInfo interface {
|
|||
AllowStaleRead() bool
|
||||
TokenSecret() string
|
||||
SetTokenSecret(string)
|
||||
HasTimedOut(since time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool
|
||||
HasTimedOut(since time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error)
|
||||
}
|
||||
|
||||
// QueryOptions is used to specify various flags for read queries
|
||||
|
@ -308,7 +308,7 @@ func (q *QueryOptions) SetTokenSecret(s string) {
|
|||
q.Token = s
|
||||
}
|
||||
|
||||
func (q QueryOptions) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool {
|
||||
func (q QueryOptions) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
||||
if q.MinQueryIndex > 0 {
|
||||
if q.MaxQueryTime > maxQueryTime {
|
||||
q.MaxQueryTime = maxQueryTime
|
||||
|
@ -317,9 +317,9 @@ func (q QueryOptions) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime,
|
|||
}
|
||||
q.MaxQueryTime += lib.RandomStagger(q.MaxQueryTime / JitterFraction)
|
||||
|
||||
return time.Since(start) > (q.MaxQueryTime + rpcHoldTimeout)
|
||||
return time.Since(start) > (q.MaxQueryTime + rpcHoldTimeout), nil
|
||||
}
|
||||
return time.Since(start) > rpcHoldTimeout
|
||||
return time.Since(start) > rpcHoldTimeout, nil
|
||||
}
|
||||
|
||||
type WriteRequest struct {
|
||||
|
@ -345,8 +345,8 @@ func (w *WriteRequest) SetTokenSecret(s string) {
|
|||
w.Token = s
|
||||
}
|
||||
|
||||
func (w WriteRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool {
|
||||
return time.Since(start) > rpcHoldTimeout
|
||||
func (w WriteRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
||||
return time.Since(start) > rpcHoldTimeout, nil
|
||||
}
|
||||
|
||||
type QueryBackend int
|
||||
|
|
|
@ -22,6 +22,6 @@ func (req *AutoConfigRequest) SetTokenSecret(token string) {
|
|||
req.ConsulToken = token
|
||||
}
|
||||
|
||||
func (req *AutoConfigRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool {
|
||||
return time.Since(start) > rpcHoldTimeout
|
||||
func (req *AutoConfigRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
||||
return time.Since(start) > rpcHoldTimeout, nil
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/proto/pbutil"
|
||||
)
|
||||
|
||||
// IsRead is always true for QueryOption
|
||||
|
@ -36,7 +37,7 @@ func (q *QueryOptions) SetMinQueryIndex(minQueryIndex uint64) {
|
|||
|
||||
// SetMaxQueryTime is needed to implement the structs.QueryOptionsCompat interface
|
||||
func (q *QueryOptions) SetMaxQueryTime(maxQueryTime time.Duration) {
|
||||
q.MaxQueryTime = maxQueryTime
|
||||
q.MaxQueryTime = *pbutil.DurationToProto(maxQueryTime)
|
||||
}
|
||||
|
||||
// SetAllowStale is needed to implement the structs.QueryOptionsCompat interface
|
||||
|
@ -56,12 +57,12 @@ func (q *QueryOptions) SetUseCache(useCache bool) {
|
|||
|
||||
// SetMaxStaleDuration is needed to implement the structs.QueryOptionsCompat interface
|
||||
func (q *QueryOptions) SetMaxStaleDuration(maxStaleDuration time.Duration) {
|
||||
q.MaxStaleDuration = maxStaleDuration
|
||||
q.MaxStaleDuration = *pbutil.DurationToProto(maxStaleDuration)
|
||||
}
|
||||
|
||||
// SetMaxAge is needed to implement the structs.QueryOptionsCompat interface
|
||||
func (q *QueryOptions) SetMaxAge(maxAge time.Duration) {
|
||||
q.MaxAge = maxAge
|
||||
q.MaxAge = *pbutil.DurationToProto(maxAge)
|
||||
}
|
||||
|
||||
// SetMustRevalidate is needed to implement the structs.QueryOptionsCompat interface
|
||||
|
@ -71,12 +72,17 @@ func (q *QueryOptions) SetMustRevalidate(mustRevalidate bool) {
|
|||
|
||||
// SetStaleIfError is needed to implement the structs.QueryOptionsCompat interface
|
||||
func (q *QueryOptions) SetStaleIfError(staleIfError time.Duration) {
|
||||
q.StaleIfError = staleIfError
|
||||
q.StaleIfError = *pbutil.DurationToProto(staleIfError)
|
||||
}
|
||||
|
||||
func (q QueryOptions) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool {
|
||||
func (q QueryOptions) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
||||
maxTime, err := pbutil.DurationFromProto(&q.MaxQueryTime)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
o := structs.QueryOptions{
|
||||
MaxQueryTime: q.MaxQueryTime,
|
||||
MaxQueryTime: maxTime,
|
||||
MinQueryIndex: q.MinQueryIndex,
|
||||
}
|
||||
return o.HasTimedOut(start, rpcHoldTimeout, maxQueryTime, defaultQueryTime)
|
||||
|
@ -88,11 +94,11 @@ func (q *QueryOptions) SetFilter(filter string) {
|
|||
}
|
||||
|
||||
// GetMaxQueryTime is required to implement blockingQueryOptions
|
||||
func (q *QueryOptions) GetMaxQueryTime() time.Duration {
|
||||
func (q *QueryOptions) GetMaxQueryTime() (time.Duration, error) {
|
||||
if q != nil {
|
||||
return q.MaxQueryTime
|
||||
return pbutil.DurationFromProto(&q.MaxQueryTime)
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetMinQueryIndex is required to implement blockingQueryOptions
|
||||
|
@ -136,19 +142,19 @@ func (q *QueryOptions) GetFilter() string {
|
|||
}
|
||||
|
||||
// GetMaxAge is required to implement structs.QueryOptionsCompat
|
||||
func (q *QueryOptions) GetMaxAge() time.Duration {
|
||||
func (q *QueryOptions) GetMaxAge() (time.Duration, error) {
|
||||
if q != nil {
|
||||
return q.MaxAge
|
||||
return pbutil.DurationFromProto(&q.MaxAge)
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetMaxStaleDuration is required to implement structs.QueryOptionsCompat
|
||||
func (q *QueryOptions) GetMaxStaleDuration() time.Duration {
|
||||
func (q *QueryOptions) GetMaxStaleDuration() (time.Duration, error) {
|
||||
if q != nil {
|
||||
return q.MaxStaleDuration
|
||||
return pbutil.DurationFromProto(&q.MaxStaleDuration)
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetMustRevalidate is required to implement structs.QueryOptionsCompat
|
||||
|
@ -160,11 +166,11 @@ func (q *QueryOptions) GetMustRevalidate() bool {
|
|||
}
|
||||
|
||||
// GetStaleIfError is required to implement structs.QueryOptionsCompat
|
||||
func (q *QueryOptions) GetStaleIfError() time.Duration {
|
||||
func (q *QueryOptions) GetStaleIfError() (time.Duration, error) {
|
||||
if q != nil {
|
||||
return q.StaleIfError
|
||||
return pbutil.DurationFromProto(&q.StaleIfError)
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetUseCache is required to implement structs.QueryOptionsCompat
|
||||
|
@ -177,7 +183,7 @@ func (q *QueryOptions) GetUseCache() bool {
|
|||
|
||||
// SetLastContact is needed to implement the structs.QueryMetaCompat interface
|
||||
func (q *QueryMeta) SetLastContact(lastContact time.Duration) {
|
||||
q.LastContact = lastContact
|
||||
q.LastContact = *pbutil.DurationToProto(lastContact)
|
||||
}
|
||||
|
||||
// SetKnownLeader is needed to implement the structs.QueryMetaCompat interface
|
||||
|
@ -229,11 +235,11 @@ func (q *QueryMeta) GetKnownLeader() bool {
|
|||
}
|
||||
|
||||
// GetLastContact is required to implement structs.QueryMetaCompat
|
||||
func (q *QueryMeta) GetLastContact() time.Duration {
|
||||
func (q *QueryMeta) GetLastContact() (time.Duration, error) {
|
||||
if q != nil {
|
||||
return q.LastContact
|
||||
return pbutil.DurationFromProto(&q.LastContact)
|
||||
}
|
||||
return 0
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// GetResultsFilteredByACLs is required to implement structs.QueryMetaCompat
|
||||
|
@ -269,8 +275,8 @@ func (w WriteRequest) AllowStaleRead() bool {
|
|||
}
|
||||
|
||||
// HasTimedOut implements structs.RPCInfo
|
||||
func (w WriteRequest) HasTimedOut(start time.Time, rpcHoldTimeout, _, _ time.Duration) bool {
|
||||
return time.Since(start) > rpcHoldTimeout
|
||||
func (w WriteRequest) HasTimedOut(start time.Time, rpcHoldTimeout, _, _ time.Duration) (bool, error) {
|
||||
return time.Since(start) > rpcHoldTimeout, nil
|
||||
}
|
||||
|
||||
// IsRead implements structs.RPCInfo
|
||||
|
@ -295,11 +301,53 @@ func (r *ReadRequest) SetTokenSecret(token string) {
|
|||
}
|
||||
|
||||
// HasTimedOut implements structs.RPCInfo
|
||||
func (r *ReadRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool {
|
||||
return time.Since(start) > rpcHoldTimeout
|
||||
func (r *ReadRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
||||
return time.Since(start) > rpcHoldTimeout, nil
|
||||
}
|
||||
|
||||
// RequestDatacenter implements structs.RPCInfo
|
||||
func (td TargetDatacenter) RequestDatacenter() string {
|
||||
return td.Datacenter
|
||||
}
|
||||
|
||||
func QueryMetaToStructs(s *QueryMeta) (structs.QueryMeta, error) {
|
||||
var t structs.QueryMeta
|
||||
if s == nil {
|
||||
return t, nil
|
||||
}
|
||||
t.Index = s.Index
|
||||
lastContact, err := pbutil.DurationFromProto(&s.LastContact)
|
||||
if err != nil {
|
||||
return t, err
|
||||
}
|
||||
t.LastContact = lastContact
|
||||
t.KnownLeader = s.KnownLeader
|
||||
t.ConsistencyLevel = s.ConsistencyLevel
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func NewQueryMetaFromStructs(s structs.QueryMeta) (*QueryMeta, error) {
|
||||
var t QueryMeta
|
||||
t.Index = s.Index
|
||||
t.LastContact = *pbutil.DurationToProto(s.LastContact)
|
||||
t.KnownLeader = s.KnownLeader
|
||||
t.ConsistencyLevel = s.ConsistencyLevel
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func RaftIndexToStructs(s *RaftIndex) structs.RaftIndex {
|
||||
if s == nil {
|
||||
return structs.RaftIndex{}
|
||||
}
|
||||
return structs.RaftIndex{
|
||||
CreateIndex: s.CreateIndex,
|
||||
ModifyIndex: s.ModifyIndex,
|
||||
}
|
||||
}
|
||||
|
||||
func NewRaftIndexFromStructs(s structs.RaftIndex) *RaftIndex {
|
||||
return &RaftIndex{
|
||||
CreateIndex: s.CreateIndex,
|
||||
ModifyIndex: s.ModifyIndex,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,20 +6,17 @@ package pbcommon
|
|||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
_ "github.com/gogo/protobuf/types"
|
||||
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
|
||||
types "github.com/gogo/protobuf/types"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
|
@ -201,7 +198,7 @@ type QueryOptions struct {
|
|||
// with MaxQueryTime.
|
||||
MinQueryIndex uint64 `protobuf:"varint,2,opt,name=MinQueryIndex,proto3" json:"MinQueryIndex,omitempty"`
|
||||
// Provided with MinQueryIndex to wait for change.
|
||||
MaxQueryTime time.Duration `protobuf:"bytes,3,opt,name=MaxQueryTime,proto3,stdduration" json:"MaxQueryTime"`
|
||||
MaxQueryTime types.Duration `protobuf:"bytes,3,opt,name=MaxQueryTime,proto3" json:"MaxQueryTime"`
|
||||
// If set, any follower can service the request. Results
|
||||
// may be arbitrarily stale.
|
||||
AllowStale bool `protobuf:"varint,4,opt,name=AllowStale,proto3" json:"AllowStale,omitempty"`
|
||||
|
@ -219,7 +216,7 @@ type QueryOptions struct {
|
|||
// If set and AllowStale is true, will try first a stale
|
||||
// read, and then will perform a consistent read if stale
|
||||
// read is older than value.
|
||||
MaxStaleDuration time.Duration `protobuf:"bytes,7,opt,name=MaxStaleDuration,proto3,stdduration" json:"MaxStaleDuration"`
|
||||
MaxStaleDuration types.Duration `protobuf:"bytes,7,opt,name=MaxStaleDuration,proto3" json:"MaxStaleDuration"`
|
||||
// MaxAge limits how old a cached value will be returned if UseCache is true.
|
||||
// If there is a cached response that is older than the MaxAge, it is treated
|
||||
// as a cache miss and a new fetch invoked. If the fetch fails, the error is
|
||||
|
@ -227,7 +224,7 @@ type QueryOptions struct {
|
|||
// StaleIfError to a longer duration to change this behavior. It is ignored
|
||||
// if the endpoint supports background refresh caching. See
|
||||
// https://www.consul.io/api/index.html#agent-caching for more details.
|
||||
MaxAge time.Duration `protobuf:"bytes,8,opt,name=MaxAge,proto3,stdduration" json:"MaxAge"`
|
||||
MaxAge types.Duration `protobuf:"bytes,8,opt,name=MaxAge,proto3" json:"MaxAge"`
|
||||
// MustRevalidate forces the agent to fetch a fresh version of a cached
|
||||
// resource or at least validate that the cached version is still fresh. It is
|
||||
// implied by either max-age=0 or must-revalidate Cache-Control headers. It
|
||||
|
@ -239,7 +236,7 @@ type QueryOptions struct {
|
|||
// UseCache is true and MaxAge is set to a lower, non-zero value. It is
|
||||
// ignored if the endpoint supports background refresh caching. See
|
||||
// https://www.consul.io/api/index.html#agent-caching for more details.
|
||||
StaleIfError time.Duration `protobuf:"bytes,10,opt,name=StaleIfError,proto3,stdduration" json:"StaleIfError"`
|
||||
StaleIfError types.Duration `protobuf:"bytes,10,opt,name=StaleIfError,proto3" json:"StaleIfError"`
|
||||
// Filter specifies the go-bexpr filter expression to be used for
|
||||
// filtering the data prior to returning a response
|
||||
Filter string `protobuf:"bytes,11,opt,name=Filter,proto3" json:"Filter,omitempty"`
|
||||
|
@ -286,7 +283,7 @@ type QueryMeta struct {
|
|||
// If AllowStale is used, this is time elapsed since
|
||||
// last contact between the follower and leader. This
|
||||
// can be used to gauge staleness.
|
||||
LastContact time.Duration `protobuf:"bytes,2,opt,name=LastContact,proto3,stdduration" json:"LastContact"`
|
||||
LastContact types.Duration `protobuf:"bytes,2,opt,name=LastContact,proto3" json:"LastContact"`
|
||||
// Used to indicate if there is a known leader node
|
||||
KnownLeader bool `protobuf:"varint,3,opt,name=KnownLeader,proto3" json:"KnownLeader,omitempty"`
|
||||
// Consistencylevel returns the consistency used to serve the query
|
||||
|
@ -387,48 +384,47 @@ func init() {
|
|||
func init() { proto.RegisterFile("proto/pbcommon/common.proto", fileDescriptor_a6f5ac44994d718c) }
|
||||
|
||||
var fileDescriptor_a6f5ac44994d718c = []byte{
|
||||
// 642 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x53, 0xd3, 0x4e,
|
||||
0x18, 0x6e, 0xf8, 0x95, 0x90, 0x6c, 0x81, 0xe9, 0x6f, 0x07, 0x9d, 0x88, 0x4e, 0x60, 0x32, 0x8c,
|
||||
0xc3, 0x30, 0xda, 0xcc, 0xa0, 0x27, 0x3d, 0xd1, 0x82, 0x0e, 0xd8, 0x88, 0xac, 0x38, 0xce, 0x78,
|
||||
0xdb, 0x26, 0x6f, 0xd3, 0x8c, 0x69, 0x36, 0xee, 0x6e, 0xa0, 0xfd, 0x16, 0x1e, 0x3c, 0xf0, 0x91,
|
||||
0x38, 0x72, 0xf4, 0x84, 0x4a, 0xbf, 0x81, 0x27, 0x8f, 0x4e, 0x36, 0x05, 0x82, 0x80, 0x53, 0x4f,
|
||||
0xed, 0xf3, 0xec, 0xf3, 0xbc, 0xfb, 0xfe, 0xdb, 0xa0, 0xfb, 0x29, 0x67, 0x92, 0xb9, 0x69, 0xc7,
|
||||
0x67, 0xfd, 0x3e, 0x4b, 0xdc, 0xe2, 0xa7, 0xa1, 0x58, 0xac, 0x17, 0x68, 0xd1, 0x0e, 0x19, 0x0b,
|
||||
0x63, 0x70, 0x15, 0xdb, 0xc9, 0xba, 0x6e, 0x90, 0x71, 0x2a, 0xa3, 0x73, 0xdd, 0xe2, 0x42, 0xc8,
|
||||
0x42, 0x56, 0x04, 0xca, 0xff, 0x15, 0xac, 0xd3, 0x47, 0x26, 0xa1, 0x5d, 0xb9, 0x9d, 0x04, 0x30,
|
||||
0xc0, 0x2e, 0xaa, 0xb5, 0x38, 0x50, 0x09, 0x0a, 0x5a, 0xda, 0xb2, 0xb6, 0x5a, 0x6d, 0xce, 0xfd,
|
||||
0x3c, 0x5d, 0x32, 0x3b, 0x30, 0x48, 0xf9, 0x33, 0xe7, 0xb1, 0x43, 0xca, 0x8a, 0xdc, 0xe0, 0xb1,
|
||||
0x20, 0xea, 0x0e, 0x0b, 0xc3, 0xd4, 0x8d, 0x86, 0x92, 0xc2, 0x59, 0x47, 0xf5, 0x7d, 0xca, 0x43,
|
||||
0x90, 0x9b, 0x54, 0x52, 0x1f, 0x12, 0x09, 0x1c, 0xdb, 0x08, 0x5d, 0x22, 0x75, 0xa9, 0x49, 0x4a,
|
||||
0x8c, 0xb3, 0x82, 0x66, 0xdf, 0xf3, 0x48, 0x02, 0x81, 0x4f, 0x19, 0x08, 0x89, 0x17, 0xd0, 0xf4,
|
||||
0x3e, 0xfb, 0x08, 0xc9, 0x58, 0x5a, 0x00, 0x67, 0x0f, 0xd5, 0x08, 0xd0, 0xe0, 0xaf, 0x22, 0xfc,
|
||||
0x08, 0xfd, 0x9f, 0x0b, 0x22, 0x0e, 0x2d, 0x96, 0x88, 0x48, 0x48, 0x48, 0xa4, 0xca, 0xda, 0x20,
|
||||
0xd7, 0x0f, 0x9c, 0x2f, 0x55, 0x34, 0xbb, 0x97, 0x01, 0x1f, 0xee, 0xa6, 0x79, 0x1f, 0xc5, 0x2d,
|
||||
0x41, 0x57, 0xd0, 0x9c, 0x17, 0x25, 0x4a, 0x58, 0x6a, 0x03, 0xb9, 0x4a, 0xe2, 0x97, 0x68, 0xd6,
|
||||
0xa3, 0x03, 0x45, 0xec, 0x47, 0x7d, 0xb0, 0xfe, 0x5b, 0xd6, 0x56, 0x6b, 0xeb, 0xf7, 0x1a, 0xc5,
|
||||
0xd4, 0x1a, 0xe7, 0x53, 0x6b, 0x6c, 0x8e, 0xa7, 0xd6, 0x34, 0x8e, 0x4f, 0x97, 0x2a, 0x47, 0xdf,
|
||||
0x96, 0x34, 0x72, 0xc5, 0x98, 0xb7, 0x6b, 0x23, 0x8e, 0xd9, 0xe1, 0x5b, 0x49, 0x63, 0xb0, 0xaa,
|
||||
0x2a, 0xf9, 0x12, 0x73, 0x73, 0x8d, 0xd3, 0xb7, 0xd4, 0x88, 0x17, 0x91, 0xf1, 0x4e, 0x40, 0x8b,
|
||||
0xfa, 0x3d, 0xb0, 0x74, 0x25, 0xba, 0xc0, 0x78, 0x17, 0xd5, 0x3d, 0x3a, 0x50, 0x51, 0xcf, 0xb3,
|
||||
0xb2, 0x66, 0x26, 0x4f, 0xfb, 0x9a, 0x19, 0x3f, 0x47, 0xba, 0x47, 0x07, 0x1b, 0x21, 0x58, 0xc6,
|
||||
0xe4, 0x61, 0xc6, 0x16, 0xfc, 0x10, 0xcd, 0x7b, 0x99, 0x90, 0x04, 0x0e, 0x68, 0x1c, 0x05, 0x54,
|
||||
0x82, 0x65, 0xaa, 0x7c, 0xff, 0x60, 0xf3, 0x46, 0xab, 0x5b, 0xb7, 0xbb, 0x5b, 0x9c, 0x33, 0x6e,
|
||||
0xa1, 0x7f, 0x68, 0x74, 0xd9, 0x88, 0xef, 0x22, 0xfd, 0x45, 0x14, 0xe7, 0x3b, 0x59, 0x53, 0xe3,
|
||||
0x1e, 0x23, 0xe7, 0x97, 0x86, 0x4c, 0x35, 0x0e, 0x0f, 0x24, 0xcd, 0x77, 0xa2, 0xf4, 0x5a, 0x48,
|
||||
0x01, 0xf0, 0x16, 0xaa, 0xb5, 0xa9, 0x90, 0x2d, 0x96, 0x48, 0xea, 0x17, 0x2b, 0x36, 0x61, 0x0e,
|
||||
0x65, 0x1f, 0x5e, 0x46, 0xb5, 0x57, 0x09, 0x3b, 0x4c, 0xda, 0x40, 0x03, 0xe0, 0x6a, 0x67, 0x0c,
|
||||
0x52, 0xa6, 0xf0, 0x1a, 0xaa, 0x5f, 0x4c, 0xd3, 0x1f, 0xb6, 0xe1, 0x00, 0x62, 0xb5, 0x13, 0x26,
|
||||
0xb9, 0xc6, 0xe3, 0xa7, 0xe8, 0x0e, 0x01, 0x91, 0xc5, 0x52, 0x14, 0x95, 0x40, 0xd0, 0x1c, 0x6e,
|
||||
0xb4, 0xda, 0x42, 0x0d, 0xd5, 0x20, 0x37, 0x1f, 0xee, 0x54, 0x8d, 0xe9, 0xba, 0xbe, 0x53, 0x35,
|
||||
0xf4, 0xfa, 0x8c, 0xd3, 0x46, 0xf3, 0x5b, 0xf9, 0x9b, 0x4c, 0x79, 0x24, 0x40, 0x95, 0xff, 0x00,
|
||||
0x99, 0xaf, 0x69, 0x1f, 0x44, 0x4a, 0x7d, 0x18, 0x3f, 0x8b, 0x4b, 0x22, 0x3f, 0x7d, 0x43, 0xb9,
|
||||
0x8c, 0xd4, 0xea, 0x4c, 0x15, 0xa7, 0x17, 0x44, 0xb3, 0x7d, 0xfc, 0xc3, 0xae, 0x1c, 0x9f, 0xd9,
|
||||
0xda, 0xc9, 0x99, 0xad, 0x7d, 0x3f, 0xb3, 0xb5, 0xcf, 0x23, 0xbb, 0x72, 0x34, 0xb2, 0x2b, 0x27,
|
||||
0x23, 0xbb, 0xf2, 0x75, 0x64, 0x57, 0x3e, 0xac, 0x85, 0x91, 0xec, 0x65, 0x9d, 0x86, 0xcf, 0xfa,
|
||||
0x6e, 0x8f, 0x8a, 0x5e, 0xe4, 0x33, 0x9e, 0xba, 0x3e, 0x4b, 0x44, 0x16, 0xbb, 0x57, 0x3f, 0x8a,
|
||||
0x1d, 0x5d, 0xe1, 0x27, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x88, 0x41, 0xa8, 0x68, 0x2d, 0x05,
|
||||
0x00, 0x00,
|
||||
// 639 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xc1, 0x6e, 0xd3, 0x4c,
|
||||
0x10, 0x8e, 0xfb, 0xa7, 0xae, 0xbd, 0x69, 0xab, 0xfc, 0xab, 0x82, 0x4c, 0x41, 0x6e, 0x65, 0x55,
|
||||
0xa8, 0xaa, 0x20, 0x96, 0x0a, 0x12, 0x12, 0xb7, 0x24, 0x2d, 0x52, 0xdb, 0x18, 0xe8, 0x52, 0x84,
|
||||
0xc4, 0x6d, 0x63, 0x4f, 0x1c, 0x0b, 0xc7, 0x6b, 0x76, 0xd7, 0x6d, 0x72, 0xe7, 0x01, 0x38, 0xf2,
|
||||
0x48, 0x3d, 0xf6, 0xc8, 0xa9, 0x82, 0xe6, 0x0d, 0x10, 0x0f, 0x80, 0xbc, 0x4e, 0x5b, 0x97, 0xa6,
|
||||
0x28, 0xa7, 0xe4, 0xfb, 0xf6, 0x9b, 0xd9, 0x99, 0xf9, 0x66, 0x8d, 0x1e, 0xa6, 0x9c, 0x49, 0xe6,
|
||||
0xa6, 0x5d, 0x9f, 0x0d, 0x06, 0x2c, 0x71, 0x8b, 0x9f, 0x86, 0x62, 0xb1, 0x5e, 0xa0, 0x55, 0x3b,
|
||||
0x64, 0x2c, 0x8c, 0xc1, 0x55, 0x6c, 0x37, 0xeb, 0xb9, 0x41, 0xc6, 0xa9, 0x8c, 0x2e, 0x75, 0xab,
|
||||
0x2b, 0x21, 0x0b, 0x59, 0x91, 0x28, 0xff, 0x57, 0xb0, 0xce, 0x00, 0x99, 0x84, 0xf6, 0xe4, 0x5e,
|
||||
0x12, 0xc0, 0x10, 0xbb, 0xa8, 0xd6, 0xe6, 0x40, 0x25, 0x28, 0x68, 0x69, 0xeb, 0xda, 0x66, 0xb5,
|
||||
0xb5, 0xf4, 0xeb, 0x7c, 0xcd, 0xec, 0xc2, 0x30, 0xe5, 0x2f, 0x9d, 0xa7, 0x0e, 0x29, 0x2b, 0xf2,
|
||||
0x00, 0x8f, 0x05, 0x51, 0x6f, 0x54, 0x04, 0xcc, 0x4d, 0x0d, 0x28, 0x29, 0x9c, 0x6d, 0x54, 0x3f,
|
||||
0xa2, 0x3c, 0x04, 0xb9, 0x43, 0x25, 0xf5, 0x21, 0x91, 0xc0, 0xb1, 0x8d, 0xd0, 0x35, 0x52, 0x97,
|
||||
0x9a, 0xa4, 0xc4, 0x38, 0x1b, 0x68, 0xf1, 0x03, 0x8f, 0x24, 0x10, 0xf8, 0x9c, 0x81, 0x90, 0x78,
|
||||
0x05, 0xcd, 0x1f, 0xb1, 0x4f, 0x90, 0x4c, 0xa4, 0x05, 0x70, 0x0e, 0x51, 0x8d, 0x00, 0x0d, 0xfe,
|
||||
0x29, 0xc2, 0x4f, 0xd0, 0xff, 0xb9, 0x20, 0xe2, 0xd0, 0x66, 0x89, 0x88, 0x84, 0x84, 0x44, 0xaa,
|
||||
0xaa, 0x0d, 0x72, 0xfb, 0xc0, 0xf9, 0x52, 0x45, 0x8b, 0x87, 0x19, 0xf0, 0xd1, 0x9b, 0x34, 0x9f,
|
||||
0xa3, 0xb8, 0x23, 0xe9, 0x06, 0x5a, 0xf2, 0xa2, 0x44, 0x09, 0x4b, 0x63, 0x20, 0x37, 0x49, 0xdc,
|
||||
0x46, 0x8b, 0x1e, 0x1d, 0x2a, 0xe2, 0x28, 0x1a, 0x80, 0xf5, 0xdf, 0xba, 0xb6, 0x59, 0xdb, 0x7e,
|
||||
0xd0, 0x28, 0x5c, 0x6b, 0x5c, 0xba, 0xd6, 0xd8, 0x99, 0xb8, 0xd6, 0xaa, 0x9e, 0x9e, 0xaf, 0x55,
|
||||
0xc8, 0x8d, 0xa0, 0x7c, 0x54, 0xcd, 0x38, 0x66, 0x27, 0xef, 0x24, 0x8d, 0xc1, 0xaa, 0xaa, 0xc2,
|
||||
0x4b, 0xcc, 0xf4, 0xfe, 0xe6, 0xef, 0xe8, 0x0f, 0xaf, 0x22, 0xe3, 0xbd, 0x80, 0x36, 0xf5, 0xfb,
|
||||
0x60, 0xe9, 0x4a, 0x74, 0x85, 0xf1, 0x01, 0xaa, 0x7b, 0x74, 0xa8, 0xb2, 0x5e, 0x56, 0x64, 0x2d,
|
||||
0xcc, 0x56, 0xf2, 0xad, 0x40, 0xfc, 0x02, 0xe9, 0x1e, 0x1d, 0x36, 0x43, 0xb0, 0x8c, 0xd9, 0x52,
|
||||
0x4c, 0xe4, 0xf8, 0x31, 0x5a, 0xf6, 0x32, 0x21, 0x09, 0x1c, 0xd3, 0x38, 0x0a, 0xa8, 0x04, 0xcb,
|
||||
0x54, 0x75, 0xfe, 0xc5, 0xe6, 0xc3, 0x55, 0x37, 0xee, 0xf5, 0x76, 0x39, 0x67, 0xdc, 0x42, 0x33,
|
||||
0x0e, 0xb7, 0x1c, 0x84, 0xef, 0x23, 0xfd, 0x55, 0x14, 0xe7, 0x3b, 0x58, 0x53, 0xf6, 0x4e, 0x90,
|
||||
0xf3, 0x5b, 0x43, 0xa6, 0xb2, 0xc0, 0x03, 0x49, 0xf3, 0x1d, 0x28, 0xbd, 0x0e, 0x52, 0x00, 0xdc,
|
||||
0x44, 0xb5, 0x0e, 0x15, 0xb2, 0xcd, 0x12, 0x49, 0xfd, 0x62, 0xa5, 0x66, 0xb8, 0xbf, 0x1c, 0x83,
|
||||
0xd7, 0x51, 0xed, 0x20, 0x61, 0x27, 0x49, 0x07, 0x68, 0x00, 0x5c, 0xed, 0x87, 0x41, 0xca, 0x14,
|
||||
0xde, 0x42, 0xf5, 0x2b, 0xf7, 0xfc, 0x51, 0x07, 0x8e, 0x21, 0x56, 0x3b, 0x60, 0x92, 0x5b, 0x3c,
|
||||
0x7e, 0x8e, 0xee, 0x11, 0x10, 0x59, 0x2c, 0x45, 0xd1, 0x05, 0x04, 0xad, 0x51, 0xb3, 0xdd, 0x11,
|
||||
0xca, 0x44, 0x83, 0x4c, 0x3f, 0xdc, 0xaf, 0x1a, 0xf3, 0x75, 0x7d, 0xbf, 0x6a, 0xe8, 0xf5, 0x05,
|
||||
0xa7, 0x83, 0x96, 0x77, 0xf3, 0xf7, 0x97, 0xf2, 0x48, 0x80, 0x6a, 0xfd, 0x11, 0x32, 0x5f, 0xd3,
|
||||
0x01, 0x88, 0x94, 0xfa, 0x30, 0x79, 0x02, 0xd7, 0x44, 0x7e, 0xfa, 0x96, 0x72, 0x19, 0xa9, 0x55,
|
||||
0x99, 0x2b, 0x4e, 0xaf, 0x88, 0x56, 0xe7, 0xf4, 0xa7, 0x5d, 0x39, 0xbd, 0xb0, 0xb5, 0xb3, 0x0b,
|
||||
0x5b, 0xfb, 0x71, 0x61, 0x6b, 0x5f, 0xc7, 0x76, 0xe5, 0xdb, 0xd8, 0xae, 0x9c, 0x8d, 0xed, 0xca,
|
||||
0xf7, 0xb1, 0x5d, 0xf9, 0xb8, 0x15, 0x46, 0xb2, 0x9f, 0x75, 0x1b, 0x3e, 0x1b, 0xb8, 0x7d, 0x2a,
|
||||
0xfa, 0x91, 0xcf, 0x78, 0xea, 0xfa, 0x2c, 0x11, 0x59, 0xec, 0xde, 0xfc, 0x00, 0x76, 0x75, 0x85,
|
||||
0x9f, 0xfd, 0x09, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x69, 0xe7, 0xf4, 0x19, 0x05, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *RaftIndex) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -591,12 +587,14 @@ func (m *QueryOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
i--
|
||||
dAtA[i] = 0x5a
|
||||
}
|
||||
n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.StaleIfError, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.StaleIfError):])
|
||||
if err1 != nil {
|
||||
return 0, err1
|
||||
{
|
||||
size, err := m.StaleIfError.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCommon(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= n1
|
||||
i = encodeVarintCommon(dAtA, i, uint64(n1))
|
||||
i--
|
||||
dAtA[i] = 0x52
|
||||
if m.MustRevalidate {
|
||||
|
@ -609,20 +607,24 @@ func (m *QueryOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
i--
|
||||
dAtA[i] = 0x48
|
||||
}
|
||||
n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxAge, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAge):])
|
||||
if err2 != nil {
|
||||
return 0, err2
|
||||
{
|
||||
size, err := m.MaxAge.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCommon(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= n2
|
||||
i = encodeVarintCommon(dAtA, i, uint64(n2))
|
||||
i--
|
||||
dAtA[i] = 0x42
|
||||
n3, err3 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxStaleDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxStaleDuration):])
|
||||
if err3 != nil {
|
||||
return 0, err3
|
||||
{
|
||||
size, err := m.MaxStaleDuration.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCommon(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= n3
|
||||
i = encodeVarintCommon(dAtA, i, uint64(n3))
|
||||
i--
|
||||
dAtA[i] = 0x3a
|
||||
if m.UseCache {
|
||||
|
@ -655,12 +657,14 @@ func (m *QueryOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
i--
|
||||
dAtA[i] = 0x20
|
||||
}
|
||||
n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxQueryTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxQueryTime):])
|
||||
if err4 != nil {
|
||||
return 0, err4
|
||||
{
|
||||
size, err := m.MaxQueryTime.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCommon(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= n4
|
||||
i = encodeVarintCommon(dAtA, i, uint64(n4))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
if m.MinQueryIndex != 0 {
|
||||
|
@ -725,12 +729,14 @@ func (m *QueryMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
i--
|
||||
dAtA[i] = 0x18
|
||||
}
|
||||
n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.LastContact, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.LastContact):])
|
||||
if err5 != nil {
|
||||
return 0, err5
|
||||
{
|
||||
size, err := m.LastContact.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCommon(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= n5
|
||||
i = encodeVarintCommon(dAtA, i, uint64(n5))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
if m.Index != 0 {
|
||||
|
@ -859,7 +865,7 @@ func (m *QueryOptions) Size() (n int) {
|
|||
if m.MinQueryIndex != 0 {
|
||||
n += 1 + sovCommon(uint64(m.MinQueryIndex))
|
||||
}
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxQueryTime)
|
||||
l = m.MaxQueryTime.Size()
|
||||
n += 1 + l + sovCommon(uint64(l))
|
||||
if m.AllowStale {
|
||||
n += 2
|
||||
|
@ -870,14 +876,14 @@ func (m *QueryOptions) Size() (n int) {
|
|||
if m.UseCache {
|
||||
n += 2
|
||||
}
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxStaleDuration)
|
||||
l = m.MaxStaleDuration.Size()
|
||||
n += 1 + l + sovCommon(uint64(l))
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxAge)
|
||||
l = m.MaxAge.Size()
|
||||
n += 1 + l + sovCommon(uint64(l))
|
||||
if m.MustRevalidate {
|
||||
n += 2
|
||||
}
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.StaleIfError)
|
||||
l = m.StaleIfError.Size()
|
||||
n += 1 + l + sovCommon(uint64(l))
|
||||
l = len(m.Filter)
|
||||
if l > 0 {
|
||||
|
@ -895,7 +901,7 @@ func (m *QueryMeta) Size() (n int) {
|
|||
if m.Index != 0 {
|
||||
n += 1 + sovCommon(uint64(m.Index))
|
||||
}
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.LastContact)
|
||||
l = m.LastContact.Size()
|
||||
n += 1 + l + sovCommon(uint64(l))
|
||||
if m.KnownLeader {
|
||||
n += 2
|
||||
|
@ -1396,7 +1402,7 @@ func (m *QueryOptions) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxQueryTime, dAtA[iNdEx:postIndex]); err != nil {
|
||||
if err := m.MaxQueryTime.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
|
@ -1489,7 +1495,7 @@ func (m *QueryOptions) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxStaleDuration, dAtA[iNdEx:postIndex]); err != nil {
|
||||
if err := m.MaxStaleDuration.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
|
@ -1522,7 +1528,7 @@ func (m *QueryOptions) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxAge, dAtA[iNdEx:postIndex]); err != nil {
|
||||
if err := m.MaxAge.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
|
@ -1575,7 +1581,7 @@ func (m *QueryOptions) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.StaleIfError, dAtA[iNdEx:postIndex]); err != nil {
|
||||
if err := m.StaleIfError.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
|
@ -1709,7 +1715,7 @@ func (m *QueryMeta) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.LastContact, dAtA[iNdEx:postIndex]); err != nil {
|
||||
if err := m.LastContact.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
|
|
|
@ -64,7 +64,7 @@ message QueryOptions {
|
|||
|
||||
// Provided with MinQueryIndex to wait for change.
|
||||
google.protobuf.Duration MaxQueryTime = 3
|
||||
[(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
[(gogoproto.nullable) = false];
|
||||
|
||||
// If set, any follower can service the request. Results
|
||||
// may be arbitrarily stale.
|
||||
|
@ -87,7 +87,7 @@ message QueryOptions {
|
|||
// read, and then will perform a consistent read if stale
|
||||
// read is older than value.
|
||||
google.protobuf.Duration MaxStaleDuration = 7
|
||||
[(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
[(gogoproto.nullable) = false];
|
||||
|
||||
// MaxAge limits how old a cached value will be returned if UseCache is true.
|
||||
// If there is a cached response that is older than the MaxAge, it is treated
|
||||
|
@ -97,7 +97,7 @@ message QueryOptions {
|
|||
// if the endpoint supports background refresh caching. See
|
||||
// https://www.consul.io/api/index.html#agent-caching for more details.
|
||||
google.protobuf.Duration MaxAge = 8
|
||||
[(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
[(gogoproto.nullable) = false];
|
||||
|
||||
// MustRevalidate forces the agent to fetch a fresh version of a cached
|
||||
// resource or at least validate that the cached version is still fresh. It is
|
||||
|
@ -112,7 +112,7 @@ message QueryOptions {
|
|||
// ignored if the endpoint supports background refresh caching. See
|
||||
// https://www.consul.io/api/index.html#agent-caching for more details.
|
||||
google.protobuf.Duration StaleIfError = 10
|
||||
[(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
[(gogoproto.nullable) = false];
|
||||
|
||||
// Filter specifies the go-bexpr filter expression to be used for
|
||||
// filtering the data prior to returning a response
|
||||
|
@ -129,7 +129,7 @@ message QueryMeta {
|
|||
// last contact between the follower and leader. This
|
||||
// can be used to gauge staleness.
|
||||
google.protobuf.Duration LastContact = 2
|
||||
[(gogoproto.stdduration) = true, (gogoproto.nullable) = false];
|
||||
[(gogoproto.nullable) = false];
|
||||
|
||||
// Used to indicate if there is a known leader node
|
||||
bool KnownLeader = 3;
|
||||
|
|
|
@ -3,4 +3,16 @@
|
|||
|
||||
package pbcommon
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
)
|
||||
|
||||
var DefaultEnterpriseMeta = EnterpriseMeta{}
|
||||
|
||||
func EnterpriseMetaToStructs(_ *EnterpriseMeta) structs.EnterpriseMeta {
|
||||
return *structs.DefaultEnterpriseMetaInDefaultPartition()
|
||||
}
|
||||
|
||||
func NewEnterpriseMetaFromStructs(_ structs.EnterpriseMeta) *EnterpriseMeta {
|
||||
return &EnterpriseMeta{}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
package pbconnect
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
"github.com/hashicorp/consul/proto/pbcommon"
|
||||
"github.com/hashicorp/consul/proto/pbutil"
|
||||
)
|
||||
|
||||
func CARootsToStructs(s *CARoots) (*structs.IndexedCARoots, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var t structs.IndexedCARoots
|
||||
t.ActiveRootID = s.ActiveRootID
|
||||
t.TrustDomain = s.TrustDomain
|
||||
t.Roots = make([]*structs.CARoot, len(s.Roots))
|
||||
for i := range s.Roots {
|
||||
root, err := CARootToStructs(s.Roots[i])
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.Roots[i] = root
|
||||
}
|
||||
queryMeta, err := pbcommon.QueryMetaToStructs(s.QueryMeta)
|
||||
if err != nil {
|
||||
return &t, nil
|
||||
}
|
||||
t.QueryMeta = queryMeta
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func NewCARootsFromStructs(s *structs.IndexedCARoots) (*CARoots, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var t CARoots
|
||||
t.ActiveRootID = s.ActiveRootID
|
||||
t.TrustDomain = s.TrustDomain
|
||||
t.Roots = make([]*CARoot, len(s.Roots))
|
||||
for i := range s.Roots {
|
||||
root, err := NewCARootFromStructs(s.Roots[i])
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.Roots[i] = root
|
||||
}
|
||||
queryMeta, err := pbcommon.NewQueryMetaFromStructs(s.QueryMeta)
|
||||
if err != nil {
|
||||
return &t, nil
|
||||
}
|
||||
t.QueryMeta = queryMeta
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func CARootToStructs(s *CARoot) (*structs.CARoot, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var t structs.CARoot
|
||||
t.ID = s.ID
|
||||
t.Name = s.Name
|
||||
t.SerialNumber = s.SerialNumber
|
||||
t.SigningKeyID = s.SigningKeyID
|
||||
t.ExternalTrustDomain = s.ExternalTrustDomain
|
||||
notBefore, err := pbutil.TimeFromProto(s.NotBefore)
|
||||
if err != nil {
|
||||
return &t, nil
|
||||
}
|
||||
t.NotBefore = notBefore
|
||||
notAfter, err := pbutil.TimeFromProto(s.NotAfter)
|
||||
if err != nil {
|
||||
return &t, nil
|
||||
}
|
||||
t.NotAfter = notAfter
|
||||
t.RootCert = s.RootCert
|
||||
if len(s.IntermediateCerts) > 0 {
|
||||
t.IntermediateCerts = make([]string, len(s.IntermediateCerts))
|
||||
copy(t.IntermediateCerts, s.IntermediateCerts)
|
||||
}
|
||||
t.SigningCert = s.SigningCert
|
||||
t.SigningKey = s.SigningKey
|
||||
t.Active = s.Active
|
||||
rotatedOutAt, err := pbutil.TimeFromProto(s.RotatedOutAt)
|
||||
if err != nil {
|
||||
return &t, nil
|
||||
}
|
||||
t.RotatedOutAt = rotatedOutAt
|
||||
t.PrivateKeyType = s.PrivateKeyType
|
||||
t.PrivateKeyBits = int(s.PrivateKeyBits)
|
||||
t.RaftIndex = pbcommon.RaftIndexToStructs(s.RaftIndex)
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func NewCARootFromStructs(s *structs.CARoot) (*CARoot, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var t CARoot
|
||||
t.ID = s.ID
|
||||
t.Name = s.Name
|
||||
t.SerialNumber = s.SerialNumber
|
||||
t.SigningKeyID = s.SigningKeyID
|
||||
t.ExternalTrustDomain = s.ExternalTrustDomain
|
||||
notBefore, err := pbutil.TimeToProto(s.NotBefore)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.NotBefore = notBefore
|
||||
notAfter, err := pbutil.TimeToProto(s.NotAfter)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.NotAfter = notAfter
|
||||
t.RootCert = s.RootCert
|
||||
if len(s.IntermediateCerts) > 0 {
|
||||
t.IntermediateCerts = make([]string, len(s.IntermediateCerts))
|
||||
copy(t.IntermediateCerts, s.IntermediateCerts)
|
||||
}
|
||||
t.SigningCert = s.SigningCert
|
||||
t.SigningKey = s.SigningKey
|
||||
t.Active = s.Active
|
||||
rotatedOutAt, err := pbutil.TimeToProto(s.RotatedOutAt)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.RotatedOutAt = rotatedOutAt
|
||||
t.PrivateKeyType = s.PrivateKeyType
|
||||
t.PrivateKeyBits = int32(s.PrivateKeyBits)
|
||||
t.RaftIndex = pbcommon.NewRaftIndexFromStructs(s.RaftIndex)
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func IssuedCertToStructs(s *IssuedCert) (*structs.IssuedCert, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var t structs.IssuedCert
|
||||
t.SerialNumber = s.SerialNumber
|
||||
t.CertPEM = s.CertPEM
|
||||
t.PrivateKeyPEM = s.PrivateKeyPEM
|
||||
t.Service = s.Service
|
||||
t.ServiceURI = s.ServiceURI
|
||||
t.Agent = s.Agent
|
||||
t.AgentURI = s.AgentURI
|
||||
validAfter, err := pbutil.TimeFromProto(s.ValidAfter)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.ValidAfter = validAfter
|
||||
validBefore, err := pbutil.TimeFromProto(s.ValidBefore)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.ValidBefore = validBefore
|
||||
t.EnterpriseMeta = pbcommon.EnterpriseMetaToStructs(s.EnterpriseMeta)
|
||||
t.RaftIndex = pbcommon.RaftIndexToStructs(s.RaftIndex)
|
||||
return &t, nil
|
||||
}
|
||||
|
||||
func NewIssuedCertFromStructs(s *structs.IssuedCert) (*IssuedCert, error) {
|
||||
if s == nil {
|
||||
return nil, nil
|
||||
}
|
||||
var t IssuedCert
|
||||
t.SerialNumber = s.SerialNumber
|
||||
t.CertPEM = s.CertPEM
|
||||
t.PrivateKeyPEM = s.PrivateKeyPEM
|
||||
t.Service = s.Service
|
||||
t.ServiceURI = s.ServiceURI
|
||||
t.Agent = s.Agent
|
||||
t.AgentURI = s.AgentURI
|
||||
validAfter, err := pbutil.TimeToProto(s.ValidAfter)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.ValidAfter = validAfter
|
||||
validBefore, err := pbutil.TimeToProto(s.ValidBefore)
|
||||
if err != nil {
|
||||
return &t, err
|
||||
}
|
||||
t.ValidBefore = validBefore
|
||||
t.EnterpriseMeta = pbcommon.NewEnterpriseMetaFromStructs(s.EnterpriseMeta)
|
||||
t.RaftIndex = pbcommon.NewRaftIndexFromStructs(s.RaftIndex)
|
||||
return &t, nil
|
||||
}
|
|
@ -28,6 +28,6 @@ func (req *SubscribeRequest) SetTokenSecret(token string) {
|
|||
}
|
||||
|
||||
// HasTimedOut implements structs.RPCInfo
|
||||
func (req *SubscribeRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) bool {
|
||||
return time.Since(start) > rpcHoldTimeout
|
||||
func (req *SubscribeRequest) HasTimedOut(start time.Time, rpcHoldTimeout, maxQueryTime, defaultQueryTime time.Duration) (bool, error) {
|
||||
return time.Since(start) > rpcHoldTimeout, nil
|
||||
}
|
||||
|
|
|
@ -13,3 +13,11 @@ func DurationToProto(d time.Duration) *types.Duration {
|
|||
func DurationFromProto(d *types.Duration) (time.Duration, error) {
|
||||
return types.DurationFromProto(d)
|
||||
}
|
||||
|
||||
func TimeFromProto(s *types.Timestamp) (time.Time, error) {
|
||||
return types.TimestampFromProto(s)
|
||||
}
|
||||
|
||||
func TimeToProto(s time.Time) (*types.Timestamp, error) {
|
||||
return types.TimestampProto(s)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue