Skip to content

Commit 1dc942d

Browse files
refactoring: first iteration without tests
1 parent cd716f0 commit 1dc942d

File tree

9 files changed

+381
-319
lines changed

9 files changed

+381
-319
lines changed

kv/kv.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ type KeyValue struct {
99
Key []byte
1010
// Value is the serialized representation of the value.
1111
Value []byte
12-
1312
// ModRevision is the revision number of the last modification to this key.
1413
ModRevision int64
1514
}

namer/generatorvalidator.go

Lines changed: 0 additions & 145 deletions
This file was deleted.

namer/generatorvalidator_test.go

Lines changed: 0 additions & 95 deletions
This file was deleted.

namer/key.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package namer
2+
3+
// KeyType represents key types.
4+
type KeyType int
5+
6+
const (
7+
// KeyTypeValue represents data type.
8+
KeyTypeValue KeyType = iota + 1
9+
// KeyTypeHash represents hash of the data type.
10+
KeyTypeHash
11+
// KeyTypeSignature represents signature of the data type.
12+
KeyTypeSignature
13+
)
14+
15+
// Key defines the minimal interface required by keys.
16+
type Key interface {
17+
Name() string // Get object name.
18+
Type() KeyType // Get key type.
19+
Property() string // Get metadata (e.g., algorithm version).
20+
Raw() []byte // Get raw data.
21+
Build() string // Reconstruct raw key string.
22+
}
23+
24+
// DefaultKey implements default realization.
25+
type DefaultKey struct {
26+
name string // Object identifier.
27+
keytype KeyType // Type of object (hash/signature/value).
28+
property string // Additional metadata (version/algorithm).
29+
raw []byte // Raw key string.
30+
}
31+
32+
// NewDefaultKey returns new Key object.
33+
func NewDefaultKey(n string, k KeyType, p string, r []byte) DefaultKey {
34+
return DefaultKey{
35+
name: n,
36+
keytype: k,
37+
property: p,
38+
raw: r,
39+
}
40+
}
41+
42+
// Name returns name of the key.
43+
func (k DefaultKey) Name() string {
44+
return k.name
45+
}
46+
47+
// Type returns type of the key.
48+
func (k DefaultKey) Type() KeyType {
49+
return k.keytype
50+
}
51+
52+
// Property returns property of the key.
53+
func (k DefaultKey) Property() string {
54+
return k.property
55+
}
56+
57+
// Raw returns raw of the key.
58+
func (k DefaultKey) Raw() []byte {
59+
return k.raw
60+
}
61+
62+
// Build should reconstruct key from signature and digest or not?
63+
func (k DefaultKey) Build() string {
64+
return string(k.raw)
65+
}
66+
67+
// String returns string representation of the `raw` field.
68+
func (k DefaultKey) String() string {
69+
return string(k.raw)
70+
}

0 commit comments

Comments
 (0)