Skip to content

Commit c36b4a8

Browse files
patapenka-alexeybigbes
authored andcommitted
namer: basic interfaces
Part of TNTP-4190
1 parent af6baee commit c36b4a8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

namer/namer.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Package namer represent interface to templates creation.
2+
package namer
3+
4+
import (
5+
"github.com/tarantool/go-storage/kv"
6+
)
7+
8+
// KeyType represents key types.
9+
type KeyType int
10+
11+
const (
12+
// KeyTypeValue represents data type.
13+
KeyTypeValue KeyType = iota + 1
14+
// KeyTypeHash represents hash of the data type.
15+
KeyTypeHash
16+
// KeyTypeSignature represents signature of the data type.
17+
KeyTypeSignature
18+
)
19+
20+
// Key implements internal realization.
21+
type Key struct {
22+
Name string // Object identificator.
23+
Type KeyType // Type of the object.
24+
Property string // Additional information (version/algorithm).
25+
}
26+
27+
// Namer represents keys naming strategy.
28+
type Namer interface {
29+
GenerateNames(name string) []string // Object's keys generation.
30+
ParseNames(names []string) []Key // Convert names into keys.
31+
}
32+
33+
// Generator generates signer K/V pairs.
34+
// Implementation should use `generic` and will used for strong typing of the solution.
35+
type Generator[T any] interface {
36+
Generate(name string, value T) ([]kv.KeyValue, error)
37+
}
38+
39+
// Validator validates and build the object from K/V.
40+
type Validator[T any] interface {
41+
Validate(pairs []kv.KeyValue) (T, error)
42+
}

0 commit comments

Comments
 (0)