private static IIpcResult RPCSendCore(ConfiguredCommand conf, IClient rpc, bool isSync) { string operationPayload = ToPayload(conf); var operation = new IpcOperation(operationPayload, waitForServerAck: isSync); return(rpc.Send(operation).GetAwaiter().GetResult()); }
/// <summary> /// Creates DaemonConfig using the values specified on the ConfiguredCommand /// </summary> public static DaemonConfig CreateDaemonConfig(ConfiguredCommand conf) { return(new DaemonConfig( logger: conf.Logger, moniker: conf.Get(Moniker), maxConnectRetries: conf.Get(MaxConnectRetries), connectRetryDelay: TimeSpan.FromMilliseconds(conf.Get(ConnectRetryDelayMillis)), stopOnFirstFailure: conf.Get(StopOnFirstFailure), enableCloudBuildIntegration: conf.Get(EnableCloudBuildIntegration))); }
/// <nodoc /> protected static int RPCSend(ConfiguredCommand conf, IClient rpc, bool isSync) { var rpcResult = RPCSendCore(conf, rpc, isSync); conf.Logger.Info( "Command '{0}' {1} (exit code: {2}). {3}", conf.Command.Name, rpcResult.Succeeded ? "succeeded" : "failed", (int)rpcResult.ExitCode, rpcResult.Payload); return((int)rpcResult.ExitCode); }
/// <summary> /// Reconstructs a full command line corresponding to a <see cref="ConfiguredCommand"/>. /// </summary> private static string ToPayload(ConfiguredCommand cmd) => ToPayload(cmd.Command.Name, cmd.Config);
/// <nodoc /> protected static int AsyncRPCSend(ConfiguredCommand conf, IClient rpc) => RPCSend(conf, rpc, false);
/// <nodoc /> protected static int SyncRPCSend(ConfiguredCommand conf, IClient rpc) => RPCSend(conf, rpc, true);
/// <summary> /// Creates anIPC client using the config from a ConfiguredCommand /// </summary> public static IClient CreateClient(ConfiguredCommand conf) { var daemonConfig = CreateDaemonConfig(conf); return(IpcProvider.GetClient(daemonConfig.Moniker, daemonConfig)); }