Remove registry from context retrieving, registry is no more in the context

main v0.3.0
René Jochum 2 years ago
parent d0ac9f2476
commit 4c8b39e70a
Signed by: jochum
GPG Key ID: F7D906F5E51E8E5E

@ -9,11 +9,6 @@ import (
"go-micro.dev/v4/errors"
)
var (
errorRetrievingComponents = errors.InternalServerError("RETRIEVING_COMPONENTS", "error while retrieving components")
errorComponentsIsNil = errors.InternalServerError("COMPONENTS_NIL", "components is nil")
)
type HealthInfo struct {
Message string `json:"message"`
IsError bool `json:"is_error"`
@ -21,8 +16,6 @@ type HealthInfo struct {
type HealthInfoMap map[string]HealthInfo
type RegistryKey struct{}
type Registry struct {
components map[string]Component
@ -30,28 +23,6 @@ type Registry struct {
flagPrefix string
}
func Context(ctx context.Context) (*Registry, error) {
c, ok := ctx.Value(RegistryKey{}).(*Registry)
if !ok {
return nil, errorRetrievingComponents
}
if c == nil {
return nil, errorComponentsIsNil
}
return c, nil
}
func Must(ctx context.Context) *Registry {
c, err := Context(ctx)
if err != nil {
panic(err)
}
return c
}
func New(service micro.Service, flagPrefix string, components ...Component) *Registry {
com := &Registry{service: service, flagPrefix: flagPrefix, components: make(map[string]Component)}

Loading…
Cancel
Save