Skip to content

Commit 2013450

Browse files
committed
feat: add Inspect option to registry
1 parent bd95ed2 commit 2013450

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

driver/factory.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"context"
88
"io/fs"
99

10+
"github.com/pkg/errors"
11+
1012
"github.com/ory/hydra/v2/driver/config"
1113
"github.com/ory/hydra/v2/fositex"
1214
"github.com/ory/x/configx"
@@ -28,6 +30,7 @@ type (
2830
extraMigrations []fs.FS
2931
goMigrations []popx.Migration
3032
fositexFactories []fositex.Factory
33+
inspect func(Registry) error
3134
}
3235
OptionsModifier func(*options)
3336

@@ -102,6 +105,12 @@ func WithExtraFositeFactories(f ...fositex.Factory) OptionsModifier {
102105
}
103106
}
104107

108+
func Inspect(f func(Registry) error) OptionsModifier {
109+
return func(o *options) {
110+
o.inspect = f
111+
}
112+
}
113+
105114
func New(ctx context.Context, sl *servicelocatorx.Options, opts []OptionsModifier) (Registry, error) {
106115
o := newOptions()
107116
for _, f := range opts {
@@ -152,6 +161,11 @@ func New(ctx context.Context, sl *servicelocatorx.Options, opts []OptionsModifie
152161
CallRegistry(ctx, r)
153162
}
154163

155-
c.Source(ctx).SetTracer(ctx, r.Tracer(ctx))
164+
if o.inspect != nil {
165+
if err := o.inspect(r); err != nil {
166+
return nil, errors.WithStack(err)
167+
}
168+
}
169+
156170
return r, nil
157171
}

0 commit comments

Comments
 (0)