From 3161b96d6dc833619ba69a8fbb8d59a04ec01bcc Mon Sep 17 00:00:00 2001 From: Alexey Potapenko Date: Tue, 25 Nov 2025 16:57:53 +0300 Subject: [PATCH] namer: basic interfaces Part of TNTP-4190 --- namer/namer.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 namer/namer.go diff --git a/namer/namer.go b/namer/namer.go new file mode 100644 index 0000000..f272a00 --- /dev/null +++ b/namer/namer.go @@ -0,0 +1,42 @@ +// Package namer represent interface to templates creation. +package namer + +import ( + "github.com/tarantool/go-storage/kv" +) + +// KeyType represents key types. +type KeyType int + +const ( + // KeyTypeValue represents data type. + KeyTypeValue KeyType = iota + 1 + // KeyTypeHash represents hash of the data type. + KeyTypeHash + // KeyTypeSignature represents signature of the data type. + KeyTypeSignature +) + +// Key implements internal realization. +type Key struct { + Name string // Object identificator. + Type KeyType // Type of the object. + Property string // Additional information (version/algorithm). +} + +// Namer represents keys naming strategy. +type Namer interface { + GenerateNames(name string) []string // Object's keys generation. + ParseNames(names []string) []Key // Convert names into keys. +} + +// Generator generates signer K/V pairs. +// Implementation should use `generic` and will used for strong typing of the solution. +type Generator[T any] interface { + Generate(name string, value T) ([]kv.KeyValue, error) +} + +// Validator validates and build the object from K/V. +type Validator[T any] interface { + Validate(pairs []kv.KeyValue) (T, error) +}