@@ -5,14 +5,9 @@ import (
5
5
"encoding/json"
6
6
"fmt"
7
7
"strings"
8
- )
9
8
10
- // Getter can get values from keys.
11
- //
12
- // The Datastore object implements this interface.
13
- type Getter interface {
14
- Get (ctx context.Context , keys ... string ) (map [string ][]byte , error )
15
- }
9
+ "github.com/OpenSlides/openslides-autoupdate-service/pkg/datastore"
10
+ )
16
11
17
12
// Fetcher is a helper to fetch many keys from the datastore.
18
13
//
@@ -24,12 +19,12 @@ type Getter interface {
24
19
//
25
20
// Make sure to call Fetcher.Err() at the end to see, if an error happend.
26
21
type Fetcher struct {
27
- getter Getter
22
+ getter datastore. Getter
28
23
err error
29
24
}
30
25
31
26
// NewFetcher initializes a Fetcher object.
32
- func NewFetcher (getter Getter ) * Fetcher {
27
+ func NewFetcher (getter datastore. Getter ) * Fetcher {
33
28
return & Fetcher {getter : getter }
34
29
}
35
30
@@ -85,7 +80,7 @@ func (f *Fetcher) FetchIfExist(ctx context.Context, value interface{}, keyFmt st
85
80
}
86
81
87
82
if fields [idField ] == nil {
88
- f .err = DoesNotExistError (fqid )
83
+ f .err = datastore . DoesNotExistError (fqid )
89
84
return
90
85
}
91
86
if fields [fqfield ] == nil {
@@ -121,7 +116,7 @@ func (f *Fetcher) Object(ctx context.Context, fqID string, fields ...string) map
121
116
}
122
117
123
118
if vals [fqID + "/id" ] == nil {
124
- f .err = DoesNotExistError (fqID )
119
+ f .err = datastore . DoesNotExistError (fqID )
125
120
return nil
126
121
}
127
122
@@ -163,11 +158,3 @@ func String(ctx context.Context, fetch FetchFunc, keyFmt string, a ...interface{
163
158
fetch (ctx , & value , keyFmt , a ... )
164
159
return value
165
160
}
166
-
167
- // DoesNotExistError is thrown by the methods of a Fetcher when an object does
168
- // not exist.
169
- type DoesNotExistError string
170
-
171
- func (e DoesNotExistError ) Error () string {
172
- return fmt .Sprintf ("%s does not exist." , string (e ))
173
- }
0 commit comments