Skip to content

Commit

Permalink
Merge pull request #54 from yandex-cloud/CLOUD-86841
Browse files Browse the repository at this point in the history
v2.0-alpha
  • Loading branch information
DavyJohnes committed Jan 12, 2022
2 parents a6dc0f4 + 12e118e commit 2c76c40
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * as cloudApi from './generated/yandex/cloud';
export * from './session';
export * from './utils/operation';
export * from './utils/decode-message';
export { WrappedServiceClientType } from './types';
14 changes: 12 additions & 2 deletions src/service-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,20 @@ const SERVICE_ENDPOINTS_LIST: ServiceEndpointsList = [
{
serviceIds: [
'yandex.cloud.logging.v1.LogGroupService',
'yandex.cloud.logging.v1.LogIngestionService',
],
endpoint: 'logging.api.cloud.yandex.net:443',
},
{
serviceIds: [
'yandex.cloud.logging.v1.LogReadingService',
],
endpoint: 'logs.api.cloud.yandex.net:443',
endpoint: 'reader.logging.yandexcloud.net:443',
},
{
serviceIds: [
'yandex.cloud.logging.v1.LogIngestionService',
],
endpoint: 'ingester.logging.yandexcloud.net:443',
},
{
serviceIds: [
Expand Down
6 changes: 3 additions & 3 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
GeneratedServiceClientCtor,
IamTokenCredentialsConfig,
OAuthCredentialsConfig,
ServiceAccountCredentialsConfig,
ServiceAccountCredentialsConfig, WrappedServiceClientType,
SessionConfig,
} from './types';
import { IamTokenService } from './token-service/iam-token-service';
Expand Down Expand Up @@ -94,8 +94,8 @@ export class Session {
return this.config.pollInterval;
}

client<S extends ServiceDefinition>(clientClass: GeneratedServiceClientCtor<S>) {
const endpoint = getServiceClientEndpoint(clientClass);
client<S extends ServiceDefinition>(clientClass: GeneratedServiceClientCtor<S>, customEndpoint?: string): WrappedServiceClientType<S> {
const endpoint = customEndpoint || getServiceClientEndpoint(clientClass);
const channel = createChannel(endpoint, this.channelCredentials);

return clientFactory.create(clientClass.service, channel);
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {
ChannelCredentials, ChannelOptions, Client, ServiceDefinition,
} from '@grpc/grpc-js';
import { RawClient } from 'nice-grpc';
import { NormalizedServiceDefinition } from 'nice-grpc/lib/service-definitions';
import { DeadlineOptions } from 'nice-grpc-client-middleware-deadline';

export interface TokenService {
getToken: () => Promise<string>;
Expand Down Expand Up @@ -48,3 +51,5 @@ export type SessionConfig =
| IamTokenCredentialsConfig
| ServiceAccountCredentialsConfig
| GenericCredentialsConfig;

export type WrappedServiceClientType<S extends ServiceDefinition> = RawClient<NormalizedServiceDefinition<S>, DeadlineOptions>;

0 comments on commit 2c76c40

Please sign in to comment.