MCPcopy
hub / github.com/lonng/nano / runGate

Function runGate

examples/customerroute/main.go:116–151  ·  view source on GitHub ↗
(args *cli.Context)

Source from the content-addressed store, hash-verified

114}
115
116func runGate(args *cli.Context) error {
117 listen := args.String("listen")
118 if listen == "" {
119 return errors.Errorf("gate listen address cannot empty")
120 }
121
122 masterAddr := args.String("master")
123 if masterAddr == "" {
124 return errors.Errorf("master address cannot empty")
125 }
126
127 gateAddr := args.String("gate-address")
128 if gateAddr == "" {
129 return errors.Errorf("gate address cannot empty")
130 }
131
132 log.Println("Current server listen address", listen)
133 log.Println("Current gate server address", gateAddr)
134 log.Println("Remote master server address", masterAddr)
135
136 // Startup Nano server with the specified listen address
137 nano.Listen(listen,
138 nano.WithAdvertiseAddr(masterAddr),
139 nano.WithClientAddr(gateAddr),
140 nano.WithComponents(onegate.Services),
141 nano.WithSerializer(json.NewSerializer()),
142 nano.WithIsWebsocket(true),
143 nano.WithWSPath("/nano"),
144 nano.WithCheckOriginFunc(func(_ *http.Request) bool { return true }),
145 nano.WithDebugMode(),
146 //set remote service route for gate
147 nano.WithCustomerRemoteServiceRoute(customerRemoteServiceRoute),
148 nano.WithNodeId(2), // if you deploy multi gate, option set nodeId, default nodeId = os.Getpid()
149 )
150 return nil
151}
152
153func runChat(args *cli.Context) error {
154 listen := args.String("listen")

Callers

nothing calls this directly

Calls 14

ListenFunction · 0.92
WithAdvertiseAddrFunction · 0.92
WithClientAddrFunction · 0.92
WithComponentsFunction · 0.92
WithSerializerFunction · 0.92
NewSerializerFunction · 0.92
WithIsWebsocketFunction · 0.92
WithWSPathFunction · 0.92
WithCheckOriginFuncFunction · 0.92
WithDebugModeFunction · 0.92
WithNodeIdFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…