Skip to content
Snippets Groups Projects
Commit 5aa60fa9 authored by Alena Petraki's avatar Alena Petraki
Browse files

refactor

parent 52472584
Branches
Tags
No related merge requests found
......@@ -20,7 +20,7 @@ const (
DefaultCacheTTL = time.Second * 10
)
func NewClient(conn *grpc.ClientConn, opts ...Option) (*Account, error) {
func NewClient(conn *grpc.ClientConn, opts ...Option) *Account {
client := &Account{}
c := &config{}
......@@ -47,7 +47,7 @@ func NewClient(conn *grpc.ClientConn, opts ...Option) (*Account, error) {
client = WithLogging(client, c.logger, c.accessLog)
}
return client, nil
return client
}
func WithCaching(client *Account, size int, ttl time.Duration) *Account {
......
......@@ -105,6 +105,11 @@ func AddAuthorizationInterceptor(auth string) grpc.UnaryClientInterceptor {
}
}
// AddAPIKeyInterceptor возвращает опции для создания grpc-соединения с передачей API-ключа при каждом запросе
func AddAPIKeyInterceptor(key string) grpc.UnaryClientInterceptor {
return AddAuthorizationInterceptor("API-Key " + key)
}
// WithOAuth2Credentials возвращает опции для создания grpc-соединения с аутентификацией oauth2. Переданный контекст
// будет использован для каждого запроса токена, поэтому он не может быть с таймаутом.
func WithOAuth2Credentials(ctx context.Context, tokenURL, clientID, clientSecret, audience string) grpc.DialOption {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment