File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ type builder struct {
27
27
nvmllib nvml.Interface
28
28
devicelib device.Interface
29
29
30
+ preHook Resolver
30
31
properties Properties
31
32
}
32
33
@@ -48,6 +49,9 @@ func New(opts ...Option) Interface {
48
49
if b .devicelib == nil {
49
50
b .devicelib = device .New (device .WithNvml (b .nvmllib ))
50
51
}
52
+ if b .preHook == nil {
53
+ b .preHook = noop {}
54
+ }
51
55
if b .properties == nil {
52
56
b .properties = & info {
53
57
root : b .root ,
@@ -79,6 +83,7 @@ func (b *builder) getResolvers() Resolver {
79
83
80
84
return firstOf ([]Resolver {
81
85
auto ,
86
+ b .preHook ,
82
87
systemMode ,
83
88
})
84
89
}
Original file line number Diff line number Diff line change @@ -52,6 +52,13 @@ func WithRoot(root string) Option {
52
52
}
53
53
}
54
54
55
+ // WithPreHookResolver provides an Option to set resolvers to use before others.
56
+ func WithPreHookResolver (preHook Resolver ) Option {
57
+ return func (i * builder ) {
58
+ i .preHook = preHook
59
+ }
60
+ }
61
+
55
62
// WithProperties provides an Option to set the Properties interface implementation.
56
63
// This is predominantly used for testing.
57
64
func WithProperties (properties Properties ) Option {
You can’t perform that action at this time.
0 commit comments