feat:multi cluster application

This commit is contained in:
pengcong06
2020-05-25 22:38:03 +08:00
parent d4b7d88b4b
commit 59839439d5
73 changed files with 9838 additions and 6278 deletions

View File

@@ -0,0 +1,25 @@
package ctxutil
import (
"context"
"google.golang.org/grpc/metadata"
)
func GetLocale(ctx context.Context) string {
locale := GetValueFromContext(ctx, localeKey)
if len(locale) == 0 {
return ""
}
return locale[0]
}
func SetLocale(ctx context.Context, locale string) context.Context {
ctx = context.WithValue(ctx, localeKey, []string{locale})
md, ok := metadata.FromOutgoingContext(ctx)
if !ok {
md = metadata.MD{}
}
md[localeKey] = []string{locale}
return metadata.NewOutgoingContext(ctx, md)
}