-
Notifications
You must be signed in to change notification settings - Fork 2
/
interfaces.go
79 lines (61 loc) · 2.11 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package gdutils
import (
"net/http"
"github.com/pawelWritesCode/gdutils/pkg/osutils"
"github.com/pawelWritesCode/gdutils/pkg/types"
)
// cacheable represents ability to store/retrieve arbitrary values.
type cacheable interface {
// Save preserve provided value under given key.
Save(key string, value any)
// GetSaved retrieve value from given key.
GetSaved(key string) (any, error)
// Reset turns cache into init state - clears all entries.
Reset()
// All returns all cache entries.
All() map[string]any
}
// debuggable defines desired debugger behaviour.
type debuggable interface {
// Print prints provided info.
Print(info string)
// IsOn tells whether debugging mode is activated.
IsOn() bool
// TurnOn turns on debugging mode.
TurnOn()
// TurnOff turns off debugging mode.
TurnOff()
// Reset resets debugging mode to init state.
Reset(isOn bool)
}
// serializable describes ability to serialize and deserialize data
type serializable interface {
// Deserialize deserializes data on v
Deserialize(data []byte, v any) error
// Serialize serializes v
Serialize(v any) ([]byte, error)
}
// requestDoer describes ability to make HTTP(s) requests.
type requestDoer interface {
Do(req *http.Request) (*http.Response, error)
}
// fileRecognizer describes entity that has ability to find file reference in input
type fileRecognizer interface {
// Recognize recognizes file reference in provided input
Recognize(input string) (osutils.FileReference, bool)
}
// pathFinder describes ability to obtain node(s) from data in fixed data format
type pathFinder interface {
// Find obtains data from bytes according to given expression
Find(expr string, bytes []byte) (any, error)
}
// templateEngine is entity that has ability to work with templates.
type templateEngine interface {
// Replace replaces template values using provided storage.
Replace(templateValue string, storage map[string]any) (string, error)
}
// typeMapper represents entity that has ability to map data's type into corresponding types.DataType of given format.
type typeMapper interface {
// Map maps data type.
Map(data any) types.DataType
}