Skip to content

Commit

Permalink
Cease to retry reflection endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
thpani committed Aug 24, 2023
1 parent 1f4d6b2 commit d04fe10
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions quint/src/quintVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,22 +246,18 @@ async function loadProtoDefViaReflection(): Promise<VerifyResult<ProtoPackageDef
const serverReflectionService = reflectionProtoDescriptor.grpc.reflection.v1alpha.ServerReflection
const reflectionClient = new serverReflectionService(APALACHE_SERVER_URI, grpc.credentials.createInsecure())

// Query reflection endpoint (retry if server is unreachable)
return retryWithTimeout(
() =>
new Promise<ServerReflectionResponse>((resolve, reject) => {
const call = reflectionClient.ServerReflectionInfo()
call.on('data', (r: ServerReflectionResponse) => {
call.end()
resolve(r)
})
call.on('error', (e: grpc.StatusObject) => reject(e))
// Query reflection endpoint
return new Promise<ServerReflectionResponse>((resolve, reject) => {
const call = reflectionClient.ServerReflectionInfo()
call.on('data', (r: ServerReflectionResponse) => {
call.end()
resolve(r)
})
call.on('error', (e: grpc.StatusObject) => reject(e))

call.write({ file_containing_symbol: 'shai.cmdExecutor.CmdExecutor' })
})
).then(response =>
call.write({ file_containing_symbol: 'shai.cmdExecutor.CmdExecutor' })
}).then(protoDefResponse => {
// Construct a proto definition of the reflection response.
response.chain((protoDefResponse: ServerReflectionResponse) => {
if ('error_response' in protoDefResponse) {
return err(
`Apalache gRPC endpoint is corrupted. Could not extract proto file: ${protoDefResponse.error_response.error_message}`
Expand All @@ -275,16 +271,17 @@ async function loadProtoDefViaReflection(): Promise<VerifyResult<ProtoPackageDef

// Use proto-loader to load the FileDescriptorProto wrapped in a FileDescriptorSet
return right(proto.loadFileDescriptorSetFromObject({ file: fileDescriptorProtos }, grpcStubOptions))
})
)
},
error => err(`Error querying reflection endpoint: ${error}`))
}

function loadGrpcClient(protoDef: ProtoPackageDefinition): AsyncCmdExecutor {
const protoDescriptor = grpc.loadPackageDefinition(protoDef)
// The cast thru `unkown` lets us convince the type system of anything
// See https://basarat.gitbook.io/typescript/type-system/type-assertion#double-assertion
const pkg = protoDescriptor.shai as unknown as ShaiPkg
const stub = new pkg.cmdExecutor.CmdExecutor(APALACHE_SERVER_URI, grpc.credentials.createInsecure())
const stub: any = new pkg.cmdExecutor.CmdExecutor(APALACHE_SERVER_URI, grpc.credentials.createInsecure())
console.log(`Connectivity state: ${stub.getChannel().getConnectivityState(true)}`)
const impl: AsyncCmdExecutor = {
run: promisify((data: RunRequest, cb: AsyncCallBack<any>) => stub.run(data, cb)),
ping: promisify((cb: AsyncCallBack<void>) => stub.ping({}, cb)),
Expand Down

0 comments on commit d04fe10

Please sign in to comment.