Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zookeeper auth supports #132

Merged
merged 8 commits into from Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/dubbo/src/registry/zookeeper.ts
Expand Up @@ -176,14 +176,18 @@ export class ZkRegistry extends Registry<IZkClientProps & IDubboRegistryProps> {
* connect zookeeper
*/
private _connect = (callback: (err: Error) => void) => {
const {url: register} = this._props;
const {url: register, zkAuthInfo} = this._props;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

//debug log
log(`connecting zkserver ${register}`);
//connect
this._client = zookeeper.createClient(register, {
retries: 10,
});

if (zkAuthInfo && zkAuthInfo.scheme && zkAuthInfo.auth) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

this._client.addAuthInfo(zkAuthInfo.scheme, Buffer.from(zkAuthInfo.auth));
}

//超时检测
//node-zookeeper-client,有个bug,当连不上zk时会无限重连
//手动做一个超时检测
Expand Down
11 changes: 10 additions & 1 deletion packages/dubbo/src/types.ts
Expand Up @@ -93,7 +93,7 @@ export interface IDubboProps {

//magic, you should use typescript 2.8+
export type TDubboService<T> = {
[k in keyof T]: T[k] extends ((dubbo: any) => infer R) ? R : any
[k in keyof T]: T[k] extends ((dubbo: any) => infer R) ? R : any;
};

export interface IDubboResult<T> {
Expand All @@ -111,7 +111,16 @@ export interface IDubboProvider {
methods: {[methodName: string]: Function};
}

// zookeeper acl shemes must be one of [ 'world', 'ip', 'host', 'auth', 'digest' ]
export type IZKAuthSchemes = 'world' | 'ip' | 'host' | 'auth' | 'digest';

export interface IZKAuthInfo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

scheme: IZKAuthSchemes;
auth: string;
}

export interface IZkClientProps {
zkAuthInfo?: IZKAuthInfo;
zkRoot?: string;
url: string;
}
Expand Down