Skip to content

Commit

Permalink
update to use new "endpoint" - feedback next
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellacosse committed Nov 12, 2024
1 parent ee8c388 commit ab29f2c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 32 deletions.
34 changes: 24 additions & 10 deletions server_manager/model/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export interface Server {
// Returns stats for bytes transferred across all access keys of this server.
getDataUsage(): Promise<BytesByAccessKey>;

// Returns tunnel time by location
getTunnelTimeByLocation(): Promise<TunnelTimeSecondsByLocation>;
// Returns server metrics
getServerMetrics(): Promise<ServerMetricsJson>;

// Adds a new access key to this server.
addAccessKey(): Promise<AccessKey>;
Expand Down Expand Up @@ -197,11 +197,25 @@ export interface DataLimit {
readonly bytes: number;
}

export type TunnelTimeSecondsByLocation = {
location: string;
asn: number;
asorg: string;
tunnel_time: {
seconds: number;
};
}[];
export type ServerMetricsJson = {
servers: {
location: string;
asn: number;
asOrg: string;
tunnelTime: {
seconds: number;
};
dataTransferred: {
bytes: number;
};
}[];
accessKeys: {
accessKeyId: number;
tunnelTime: {
seconds: number;
};
dataTransferred: {
bytes: number;
};
}[];
};
6 changes: 3 additions & 3 deletions server_manager/www/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1079,12 +1079,12 @@ export class App {
selectedServer: server_model.Server,
serverView: ServerView
) {
const tunnelTimeByLocation = await selectedServer.getTunnelTimeByLocation();
const serverMetrics = await selectedServer.getServerMetrics();

let sum = 0;
for (const {
tunnel_time: {seconds},
} of tunnelTimeByLocation) {
tunnelTime: {seconds},
} of serverMetrics.servers) {
sum += seconds / (60 * 60);
}

Expand Down
62 changes: 45 additions & 17 deletions server_manager/www/shadowbox_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,54 @@ export class ShadowboxServer implements server.Server {
return usageMap;
}

async getTunnelTimeByLocation(): Promise<server.TunnelTimeSecondsByLocation> {
async getServerMetrics(): Promise<server.ServerMetricsJson> {
//TODO
return [
{
location: 'CA',
asn: 1,
asorg: 'IDK',
tunnel_time: {
seconds: 10000,
return {
servers: [
{
location: 'CA',
asn: 1,
asOrg: 'IDK',
tunnelTime: {
seconds: 10000,
},
dataTransferred: {
bytes: 10000,
},
},
},
{
location: 'US',
asn: 2,
asorg: 'WHATEVER',
tunnel_time: {
seconds: 200000,
{
location: 'US',
asn: 2,
asOrg: 'WHATEVER',
tunnelTime: {
seconds: 200000,
},
dataTransferred: {
bytes: 200000,
},
},
},
];
],
accessKeys: [
{
accessKeyId: 0,
tunnelTime: {
seconds: 10000,
},
dataTransferred: {
bytes: 10000,
},
},
{
accessKeyId: 1,
tunnelTime: {
seconds: 200000,
},
dataTransferred: {
bytes: 200000,
},
},
],
};
}

getName(): string {
Expand Down
29 changes: 27 additions & 2 deletions server_manager/www/testing/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,33 @@ export class FakeServer implements server.Server {
getDataUsage() {
return Promise.resolve(new Map<server.AccessKeyId, number>());
}
getTunnelTimeByLocation() {
return Promise.resolve([]);
getServerMetrics() {
return Promise.resolve({
servers: [
{
location: '',
asn: 0,
asOrg: '',
tunnelTime: {
seconds: 0,
},
dataTransferred: {
bytes: 0,
},
},
],
accessKeys: [
{
accessKeyId: 0,
tunnelTime: {
seconds: 0,
},
dataTransferred: {
bytes: 0,
},
},
],
});
}
addAccessKey() {
const accessKey = {
Expand Down

0 comments on commit ab29f2c

Please sign in to comment.