/// <summary> /// Starts a new complex or returns the existing complex /// </summary> /// <param name="context">The context that the complex will inherit</param> /// <param name="servers"></param> public static async Task <AgentComplex> complex(AgentContext context) { if (AgentComplex.Complex.IsSome()) { return(AgentComplex.Complex.ValueOrDefault()); } var servers = 40; var complex = new AgentComplex(context); var configs = root.list <AgentServerConfig>(); var processors = Environment.ProcessorCount; term.inform($"Server complex using {processors} processor cores"); for (uint i = 0, corenum = 1; i <= servers; i++, corenum++) { var sid = AgentIdentityPool.NextServerId(); var config = new AgentServerConfig(sid, $"Server{sid}", corenum); term.babble($"Defined configuration for {config}"); configs.Add(config); if (corenum == processors) { corenum = 0; } } var eventSink = TraceEventSink.Define(context, (complex.PartId, complex.HostId)); complex.Configure(configs, eventSink); await complex.Start(); AgentComplex.Complex = complex; return(complex); }
internal AgentServer(IAgentContext context, AgentServerConfig config) : base(context, (config.ServerId, 0u))
public static AgentServer server(IAgentContext context, AgentServerConfig config) => new AgentServer(context, config);