1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-03-17 20:28:06 +02:00
2021-12-05 11:55:54 +00:00

28 lines
712 B
Go

package mock
import (
"context"
)
type responseKey struct{}
func responseFromContext(ctx context.Context) (map[string][]MockResponse, bool) {
r, ok := ctx.Value(responseKey{}).(map[string][]MockResponse)
return r, ok
}
func newResponseContext(ctx context.Context, r map[string][]MockResponse) context.Context {
return context.WithValue(ctx, responseKey{}, r)
}
type subscriberKey struct{}
func subscriberFromContext(ctx context.Context) (map[string]MockSubscriber, bool) {
r, ok := ctx.Value(subscriberKey{}).(map[string]MockSubscriber)
return r, ok
}
func newSubscriberContext(ctx context.Context, r map[string]MockSubscriber) context.Context {
return context.WithValue(ctx, subscriberKey{}, r)
}