Skip to content

Commit ba5dc9c

Browse files
committed
WIP - service versioning.
1 parent fa85884 commit ba5dc9c

6 files changed

Lines changed: 51 additions & 4 deletions

File tree

src/PolykeyAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { SessionManager } from './sessions';
2222
import { certNodeId } from './network/utils';
2323
import { IdentitiesManager } from './identities';
2424
import { ForwardProxy, ReverseProxy } from './network';
25-
import { IAgentServer } from './proto/js/Agent_grpc_pb';
25+
import { IAgentServer } from './proto/js/Agent.v2_grpc_pb';
2626
import { IClientServer } from './proto/js/Client_grpc_pb';
2727
import { createAgentService, AgentService } from './agent';
2828
import { createClientService, ClientService } from './client';

src/agent/agentService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Sigchain } from '../sigchain';
1414
import { KeyManager } from '../keys';
1515
import { NotificationsManager } from '../notifications';
1616
import { ErrorGRPC } from '../grpc/errors';
17-
import { AgentService, IAgentServer } from '../proto/js/Agent_grpc_pb';
17+
import { AgentService, IAgentServer } from '../proto/js/Agent.v2_grpc_pb';
1818

1919
import { messages } from '.';
2020
import * as grpcUtils from '../grpc/utils';
@@ -47,7 +47,7 @@ function createAgentService({
4747
notificationsManager: NotificationsManager;
4848
}): IAgentServer {
4949
const agentService: IAgentServer = {
50-
echo: async (
50+
echoNew: async (
5151
call: grpc.ServerUnaryCall<
5252
messages.common.EchoMessage,
5353
messages.common.EchoMessage

src/grpc/GRPCServer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ class GRPCServer {
194194
return;
195195
}
196196

197-
@ready(new grpcErrors.ErrorGRPCServerNotStarted())
198197
public closeServerForce(): void {
199198
this.server.forceShutdown();
200199
}

src/proto/schemas/Agent.v2.proto

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
syntax = "proto3";
2+
3+
import "Common.proto";
4+
import "Nodes.proto";
5+
import "Vaults.proto";
6+
import "Notifications.proto";
7+
8+
package agentInterface.v2;
9+
10+
service Agent {
11+
12+
// Echo
13+
rpc EchoNew(common.EchoMessage) returns (common.EchoMessage);
14+
15+
// Vaults
16+
rpc VaultsGitInfoGet (vault.Vault) returns (stream vault.PackChunk);
17+
rpc VaultsGitPackGet(stream vault.PackChunk) returns (stream vault.PackChunk);
18+
rpc VaultsScan (node.Node) returns (stream vault.Vault);
19+
rpc VaultsPermisssionsCheck (vault.NodePermission) returns (vault.NodePermissionAllowed);
20+
21+
// Nodes
22+
rpc NodesClosestLocalNodesGet (node.Node) returns (node.NodeTable);
23+
rpc NodesClaimsGet (node.ClaimType) returns (node.Claims);
24+
rpc NodesChainDataGet (common.EmptyMessage) returns (node.ChainData);
25+
rpc NodesHolePunchMessageSend (node.Relay) returns (common.EmptyMessage);
26+
rpc NodesCrossSignClaim (stream node.CrossSign) returns (stream node.CrossSign);
27+
28+
// Notifications
29+
rpc NotificationsSend (notification.AgentNotification) returns (common.EmptyMessage);
30+
}

src/vaults/VaultManager.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ class VaultManager {
216216
this.logger.info('Destroyed Vault Manager');
217217
}
218218

219+
/**
220+
* Gets the name of the vault with vaultId
221+
* @param vaultId - Id of the vault.
222+
* @returns {VaultName} - Name of the vault.
223+
* @throws ErrorVaultUndefined if no vault matches the provided VaultId
224+
*/
219225
@ready(new vaultsErrors.ErrorVaultManagerDestroyed())
220226
public async getVaultName(vaultId: VaultId): Promise<VaultName | undefined> {
221227
const vaultMeta = await this.db.get<POJO>(
@@ -226,6 +232,11 @@ class VaultManager {
226232
return vaultMeta.name;
227233
}
228234

235+
/**
236+
* Creates a vault with the vaultName.
237+
* @param vaultName
238+
* @returns {*}
239+
*/
229240
@ready(new vaultsErrors.ErrorVaultManagerDestroyed())
230241
public async createVault(vaultName: VaultName): Promise<Vault> {
231242
const vaultId = await this.generateVaultId();

tests/agent/GRPCClientAgent.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,4 +407,11 @@ describe('GRPC agent', () => {
407407
expect(sigchain.locked).toBe(false);
408408
});
409409
});
410+
test('trying to call a service that is not supported.', async () => {
411+
const echoMessage = new messages.common.EchoMessage();
412+
echoMessage.setChallenge('yes');
413+
await client.echo(echoMessage);
414+
const response = await client.echo(echoMessage);
415+
expect(response.getChallenge()).toBe('yes');
416+
})
410417
});

0 commit comments

Comments
 (0)