From ffe826adff14f7c433962139dffda9f88e8f0b4c Mon Sep 17 00:00:00 2001 From: Jack Kawell Date: Fri, 23 Aug 2024 16:47:26 -0500 Subject: [PATCH] feat: disable mux (#40) Add the option to entirely disable the mux server for applications that don't need any network server at all. --- pkg/chassis/builder.go | 9 ++++++++- pkg/chassis/runtime.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/chassis/builder.go b/pkg/chassis/builder.go index 822e834..7abe505 100644 --- a/pkg/chassis/builder.go +++ b/pkg/chassis/builder.go @@ -102,6 +102,11 @@ func (c *Runtime) WithRoute(route *ntv1.Route) *Runtime { return c } +func (c *Runtime) DisableMux() *Runtime { + c.noMux = true + return c +} + // ///////////////// // System Functions // ///////////////// @@ -214,7 +219,9 @@ func (c *Runtime) Start() { c.runRPC(close, handler) } - go c.runMux(close, handler) + if !c.noMux { + go c.runMux(close, handler) + } // TODO: start consumers diff --git a/pkg/chassis/runtime.go b/pkg/chassis/runtime.go index ee48453..bfc0cd3 100644 --- a/pkg/chassis/runtime.go +++ b/pkg/chassis/runtime.go @@ -14,6 +14,7 @@ type Runtime struct { repositories []Repository secretStores []SecretStore isRPC bool + noMux bool rpcReflectionServiceNames []string mux *http.ServeMux consensusKind ConsensusKind