• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import * as path from 'path';
17
18const profilerServicePath = path.join(__dirname, '../proto', 'profiler_service.proto');
19
20export class ProfilerClient {
21    // proto filePaths
22    private _filePaths: Array<String> | undefined;
23    // client
24    private _client: any;
25    // profiler_proto
26    private _profiler_proto: any;
27
28    // ProfilerClient constructor
29    public constructor(address: Address) {
30        // load client port
31        let clientPort = this.loadAddress(address);
32        // load proto file
33        this.start(clientPort, profilerServicePath);
34    };
35
36    get filePaths(): Array<String> | undefined {
37        return this._filePaths;
38    }
39
40    set filePaths(value: Array<String> | undefined) {
41        this._filePaths = value;
42    }
43
44    get client(): any {
45        return this._client;
46    }
47
48    set client(value: any) {
49        this._client = value;
50    }
51
52    get profiler_proto(): any {
53        return this._profiler_proto;
54    }
55
56    set profiler_proto(value: any) {
57        this._profiler_proto = value;
58    }
59
60    start(address: string, filePath: string) {
61    }
62
63    // Address
64    loadAddress(clientAddress: Address): string {
65        return clientAddress.host + ':' + clientAddress.port;
66    };
67
68    public getProfilerClient(callback: any): any {
69        return this._client;
70    };
71
72    public getCapabilities(callback: any) {
73        this._client.this._client.getCapabilities(callback);
74        callback();
75    };
76
77    public createSession(callback: any) {
78        this._client.createSession(callback);
79        callback();
80    };
81
82    public startSession(callback: any) {
83        this._client.startSession(callback);
84        callback();
85    };
86
87    public stopSession(callback: any) {
88        this._client.stopSession(callback);
89        callback();
90    };
91
92    public destroySession(callback: any) {
93        this._client.destroySession(callback);
94        callback();
95    };
96
97    public keepSession(callback: any) {
98        this._client.keepSession(callback);
99        callback();
100    };
101
102    public shutdown(): void {
103
104    };
105
106    public getChannel() {
107        return this._client.channelInterpretation;
108    };
109
110}
111
112export interface Address {
113    // port
114    port: string | number;
115
116    // host
117    host?: string | number;
118}
119