-
Notifications
You must be signed in to change notification settings - Fork 7
/
GeneralInfoServiceBinaryHttp.ts
54 lines (45 loc) · 2.1 KB
/
GeneralInfoServiceBinaryHttp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// =========================================================================================
// ExecutionGraph
// Copyright (C) 2014 by Gabriel Nützi <gnuetzi (at) gmail (døt) com>
//
// @date Sun Jul 29 2018
// @author Simon Spoerri, simon (døt) spoerri (at) gmail (døt) com
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// =========================================================================================
import { Injectable, Inject } from '@angular/core';
import { VERBOSE_LOG_TOKEN } from '../tokens';
import { flatbuffers } from 'flatbuffers';
import { ILogger, LoggerFactory } from '@eg/logger';
import { GeneralInfoService, sz } from './GeneralInfoService';
import { BinaryHttpRouterService } from './BinaryHttpRouterService';
import * as model from '../model';
import * as conversions from './Conversions';
@Injectable()
export class GeneralInfoServiceBinaryHttp extends GeneralInfoService {
private logger: ILogger;
constructor(
loggerFactory: LoggerFactory,
private readonly binaryRouter: BinaryHttpRouterService,
@Inject(VERBOSE_LOG_TOKEN) private readonly verboseResponseLog = true
) {
super();
this.logger = loggerFactory.create('GeneralInfoServiceBinaryHttp');
}
public async getAllGraphTypeDescriptions(): Promise<model.GraphTypeDescription[]> {
const result = await this.binaryRouter.get('general/getAllGraphTypeDescriptions');
let buf = new flatbuffers.ByteBuffer(result);
let response = sz.GetAllGraphTypeDescriptionsResponse.getRootAsGetAllGraphTypeDescriptionsResponse(buf);
this.logger.info(`Number of graph types: ${response.graphsTypesLength()}`);
let graphDesc: model.GraphTypeDescription[] = [];
for (let g = 0; g < response.graphsTypesLength(); ++g) {
graphDesc.push(conversions.toGraphTypeDescription(response.graphsTypes(g)));
}
if (this.verboseResponseLog) {
this.logger.debug(`GraphDescriptions: ${JSON.stringify(graphDesc)}`);
}
return graphDesc;
}
}