-
Notifications
You must be signed in to change notification settings - Fork 7
/
factory.go
30 lines (25 loc) · 929 Bytes
/
factory.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
package uuid
import (
uuidtest "github.com/ankorstore/yokai/generate/generatetest/uuid"
"github.com/ankorstore/yokai/generate/uuid"
"go.uber.org/fx"
)
// FxTestUuidGeneratorFactoryParam is used to retrieve the provided generate-test-uuid-value from Fx.
type FxTestUuidGeneratorFactoryParam struct {
fx.In
Value string `name:"generate-test-uuid-value"`
}
// TestUuidGeneratorFactory is a [uuid.UuidGeneratorFactory] implementation.
type TestUuidGeneratorFactory struct {
value string
}
// NewFxTestUuidGeneratorFactory returns a new [TestUuidGeneratorFactory], implementing [uuid.UuidGeneratorFactory].
func NewFxTestUuidGeneratorFactory(p FxTestUuidGeneratorFactoryParam) uuid.UuidGeneratorFactory {
return &TestUuidGeneratorFactory{
value: p.Value,
}
}
// Create returns a new [uuid.UuidGenerator].
func (f *TestUuidGeneratorFactory) Create() uuid.UuidGenerator {
return uuidtest.NewTestUuidGenerator(f.value)
}