mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-07-24 15:55:17 -04:00
fix stuttering StoreValueUnsetError
This commit is contained in:
parent
5660f813f0
commit
b1818ba089
5 changed files with 9 additions and 9 deletions
|
@ -73,7 +73,7 @@ func (s *EtcdStore) Get(request string) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if values.Count == 0 {
|
if values.Count == 0 {
|
||||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
return nil, &ValueUnsetError{requestedValue: request}
|
||||||
}
|
}
|
||||||
if values.Count == 1 {
|
if values.Count == 1 {
|
||||||
return values.Kvs[0].Value, nil
|
return values.Kvs[0].Value, nil
|
||||||
|
@ -150,7 +150,7 @@ func (t *EtcdTransaction) Get(request string) ([]byte, error) {
|
||||||
return value, nil
|
return value, nil
|
||||||
}
|
}
|
||||||
if _, ok := t.dataDelete[request]; ok {
|
if _, ok := t.dataDelete[request]; ok {
|
||||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
return nil, &ValueUnsetError{requestedValue: request}
|
||||||
}
|
}
|
||||||
return t.store.Get(request)
|
return t.store.Get(request)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (s *StdStore) Get(request string) ([]byte, error) {
|
||||||
if ok {
|
if ok {
|
||||||
return []byte(value), nil
|
return []byte(value), nil
|
||||||
}
|
}
|
||||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
return nil, &ValueUnsetError{requestedValue: request}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put saves a value in StdStore by Type and Name.
|
// Put saves a value in StdStore by Type and Name.
|
||||||
|
@ -119,7 +119,7 @@ func (t *stdTransaction) Get(request string) ([]byte, error) {
|
||||||
if value, ok := t.data[request]; ok {
|
if value, ok := t.data[request]; ok {
|
||||||
return []byte(value), nil
|
return []byte(value), nil
|
||||||
}
|
}
|
||||||
return nil, &StoreValueUnsetError{requestedValue: request}
|
return nil, &ValueUnsetError{requestedValue: request}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put saves a value.
|
// Put saves a value.
|
||||||
|
|
|
@ -44,12 +44,12 @@ type Iterator interface {
|
||||||
HasNext() bool
|
HasNext() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoreValueUnsetError is an error raised by unset values in the store.
|
// ValueUnsetError is an error raised by unset values in the store.
|
||||||
type StoreValueUnsetError struct {
|
type ValueUnsetError struct {
|
||||||
requestedValue string
|
requestedValue string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error implements the Error interface.
|
// Error implements the Error interface.
|
||||||
func (s *StoreValueUnsetError) Error() string {
|
func (s *ValueUnsetError) Error() string {
|
||||||
return fmt.Sprintf("store: requested value not set: %s", s.requestedValue)
|
return fmt.Sprintf("store: requested value not set: %s", s.requestedValue)
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ func testBasic(t *testing.T) {
|
||||||
|
|
||||||
_, err = store.Get("invalid:key")
|
_, err = store.Get("invalid:key")
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
var unsetErr *StoreValueUnsetError
|
var unsetErr *ValueUnsetError
|
||||||
assert.ErrorAs(err, &unsetErr)
|
assert.ErrorAs(err, &unsetErr)
|
||||||
assert.NoError(store.Delete("test:input"))
|
assert.NoError(store.Delete("test:input"))
|
||||||
assert.NoError(store.Delete("another:input"))
|
assert.NoError(store.Delete("another:input"))
|
||||||
|
|
|
@ -107,7 +107,7 @@ func (s StoreWrapper) GetPeers() ([]peer.Peer, error) {
|
||||||
// Should be called in a transaction together with Add/Remove operation(s).
|
// Should be called in a transaction together with Add/Remove operation(s).
|
||||||
func (s StoreWrapper) IncrementPeersResourceVersion() error {
|
func (s StoreWrapper) IncrementPeersResourceVersion() error {
|
||||||
val, err := s.GetPeersResourceVersion()
|
val, err := s.GetPeersResourceVersion()
|
||||||
var unsetErr *store.StoreValueUnsetError
|
var unsetErr *store.ValueUnsetError
|
||||||
if errors.As(err, &unsetErr) {
|
if errors.As(err, &unsetErr) {
|
||||||
val = 0
|
val = 0
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue