How to use the @bentley/certa/lib/utils/CallbackUtils.registerBackendCallback function in @bentley/certa

To help you get started, we’ve selected a few @bentley/certa examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / integration-tests / rpc / src / backend / http.ts View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
import { BentleyCloudRpcManager } from "@bentley/imodeljs-common";
import { rpcInterfaces } from "../common/TestRpcInterface";
import { IModelJsExpressServer } from "@bentley/express-server";

import { registerBackendCallback } from "@bentley/certa/lib/utils/CallbackUtils";
import { BackendTestCallbacks } from "../common/SideChannels";
import "./CommonBackendSetup";

registerBackendCallback(BackendTestCallbacks.getEnvironment, () => "http");

async function init() {
  const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "rpc-integration-test", version: "v1.0" } }, rpcInterfaces);

  // create a basic express web server
  const port = Number(process.env.CERTA_PORT || 3021) + 2000;
  const server = new IModelJsExpressServer(rpcConfig.protocol);
  await server.initialize(port);
  // tslint:disable-next-line:no-console
  console.log("Web backend for integration-tests listening on port " + port);
}

module.exports = init();
github imodeljs / imodeljs / integration-tests / rpc / src / backend / CommonBackendSetup.ts View on Github external
import { BackendTestCallbacks } from "../common/SideChannels";
import { TestRpcImpl2, resetOp8Initializer } from "./TestRpcImpl";

IModelJsConfig.init(true, true, Config.App);
RpcConfiguration.developmentMode = true;

// Start the backend
IModelHost.startup();

registerBackendCallback(BackendTestCallbacks.registerTestRpcImpl2Class, () => {
  TestRpcImpl2.register();
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.replaceTestRpcImpl2Instance, () => {
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.unregisterTestRpcImpl2Class, () => {
  TestRpcImpl2.unregister();
  return true;
});

registerBackendCallback(BackendTestCallbacks.setIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = "0.0.0";
  return true;
});

const compatibleVersion = IModelReadRpcInterface.interfaceVersion;
registerBackendCallback(BackendTestCallbacks.restoreIncompatibleInterfaceVersion, () => {
github imodeljs / imodeljs / integration-tests / rpc / src / backend / CommonBackendSetup.ts View on Github external
import { IModelHost } from "@bentley/imodeljs-backend";
import { RpcConfiguration, IModelReadRpcInterface } from "@bentley/imodeljs-common";
import { Logger, LogLevel } from "@bentley/bentleyjs-core";
import { IModelJsConfig } from "@bentley/config-loader/lib/IModelJsConfig";
import { Config } from "@bentley/imodeljs-clients";
import { registerBackendCallback } from "@bentley/certa/lib/utils/CallbackUtils";
import { BackendTestCallbacks } from "../common/SideChannels";
import { TestRpcImpl2, resetOp8Initializer } from "./TestRpcImpl";

IModelJsConfig.init(true, true, Config.App);
RpcConfiguration.developmentMode = true;

// Start the backend
IModelHost.startup();

registerBackendCallback(BackendTestCallbacks.registerTestRpcImpl2Class, () => {
  TestRpcImpl2.register();
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.replaceTestRpcImpl2Instance, () => {
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.unregisterTestRpcImpl2Class, () => {
  TestRpcImpl2.unregister();
  return true;
});

registerBackendCallback(BackendTestCallbacks.setIncompatibleInterfaceVersion, () => {
github imodeljs / imodeljs / integration-tests / rpc / src / backend / CommonBackendSetup.ts View on Github external
// Start the backend
IModelHost.startup();

registerBackendCallback(BackendTestCallbacks.registerTestRpcImpl2Class, () => {
  TestRpcImpl2.register();
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.replaceTestRpcImpl2Instance, () => {
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.unregisterTestRpcImpl2Class, () => {
  TestRpcImpl2.unregister();
  return true;
});

registerBackendCallback(BackendTestCallbacks.setIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = "0.0.0";
  return true;
});

const compatibleVersion = IModelReadRpcInterface.interfaceVersion;
registerBackendCallback(BackendTestCallbacks.restoreIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = compatibleVersion;
  return true;
});

registerBackendCallback(BackendTestCallbacks.resetOp8Initializer, () => {
github imodeljs / imodeljs / integration-tests / rpc / src / backend / CommonBackendSetup.ts View on Github external
TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.unregisterTestRpcImpl2Class, () => {
  TestRpcImpl2.unregister();
  return true;
});

registerBackendCallback(BackendTestCallbacks.setIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = "0.0.0";
  return true;
});

const compatibleVersion = IModelReadRpcInterface.interfaceVersion;
registerBackendCallback(BackendTestCallbacks.restoreIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = compatibleVersion;
  return true;
});

registerBackendCallback(BackendTestCallbacks.resetOp8Initializer, () => {
  resetOp8Initializer();
  return true;
});

Logger.initializeToConsole();
Logger.setLevel("imodeljs-backend.IModelReadRpcImpl", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("imodeljs-backend.IModelDb", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("Performance", LogLevel.Error);  // Change to Info to capture
github imodeljs / imodeljs / integration-tests / rpc / src / backend / CommonBackendSetup.ts View on Github external
TestRpcImpl2.unregister();
  return true;
});

registerBackendCallback(BackendTestCallbacks.setIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = "0.0.0";
  return true;
});

const compatibleVersion = IModelReadRpcInterface.interfaceVersion;
registerBackendCallback(BackendTestCallbacks.restoreIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = compatibleVersion;
  return true;
});

registerBackendCallback(BackendTestCallbacks.resetOp8Initializer, () => {
  resetOp8Initializer();
  return true;
});

Logger.initializeToConsole();
Logger.setLevel("imodeljs-backend.IModelReadRpcImpl", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("imodeljs-backend.IModelDb", LogLevel.Error);  // Change to trace to debug
Logger.setLevel("Performance", LogLevel.Error);  // Change to Info to capture
github imodeljs / imodeljs / integration-tests / rpc / src / backend / CommonBackendSetup.ts View on Github external
TestRpcImpl2.register();
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.replaceTestRpcImpl2Instance, () => {
  TestRpcImpl2.instantiate();
  return true;
});

registerBackendCallback(BackendTestCallbacks.unregisterTestRpcImpl2Class, () => {
  TestRpcImpl2.unregister();
  return true;
});

registerBackendCallback(BackendTestCallbacks.setIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = "0.0.0";
  return true;
});

const compatibleVersion = IModelReadRpcInterface.interfaceVersion;
registerBackendCallback(BackendTestCallbacks.restoreIncompatibleInterfaceVersion, () => {
  IModelReadRpcInterface.interfaceVersion = compatibleVersion;
  return true;
});

registerBackendCallback(BackendTestCallbacks.resetOp8Initializer, () => {
  resetOp8Initializer();
  return true;
});

Logger.initializeToConsole();

@bentley/certa

A mocha-based integration test runner

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis