-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathhost.go
More file actions
64 lines (53 loc) · 1.16 KB
/
host.go
File metadata and controls
64 lines (53 loc) · 1.16 KB
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
package ferret
import (
"github.com/MontFerret/ferret/v2/pkg/encoding"
"github.com/MontFerret/ferret/v2/pkg/runtime"
)
type (
HostConfigurer interface {
Params() runtime.Params
Library() runtime.Library
Encoding() encoding.CodecRegistrar
}
host struct {
functions *runtime.Functions
params runtime.Params
encoding *encoding.Registry
logging runtime.LogSettings
}
hostBuilder struct {
library runtime.Library
params runtime.Params
encoding *encoding.Registry
logging runtime.LogSettings
}
)
func newHostBuilder(opts *options) *hostBuilder {
return &hostBuilder{
library: opts.library,
params: opts.params,
logging: opts.logging,
encoding: opts.encoding,
}
}
func (h *hostBuilder) Params() runtime.Params {
return h.params
}
func (h *hostBuilder) Library() runtime.Library {
return h.library
}
func (h *hostBuilder) Encoding() encoding.CodecRegistrar {
return h.encoding
}
func (h *hostBuilder) Build() (*host, error) {
funcs, err := h.library.Build()
if err != nil {
return nil, err
}
return &host{
logging: h.logging,
functions: funcs,
params: h.params.Clone(),
encoding: h.encoding.Clone(),
}, nil
}