MCPcopy Create free account
hub / github.com/encodeous/nylon / handleIPCReload

Function handleIPCReload

core/ipc_handler.go:436–470  ·  view source on GitHub ↗
(n *Nylon, req *protocol.ReloadRequest)

Source from the content-addressed store, hash-verified

434}
435
436func handleIPCReload(n *Nylon, req *protocol.ReloadRequest) *protocol.IpcResponse {
437 data, err := os.ReadFile(n.ConfigPath)
438 if err != nil {
439 return errResponse(fmt.Sprintf("read file: %v", err))
440 }
441 var cfg state.CentralCfg
442 if err = yaml.Unmarshal(data, &cfg); err != nil {
443 return errResponse(fmt.Sprintf("parse config: %v", err))
444 }
445 // We're running on the dispatch goroutine, so call ApplyCentralConfig
446 // directly rather than re-dispatching (which would deadlock).
447 result, err := n.ApplyCentralConfig(&cfg)
448 msg := ""
449 if err != nil {
450 msg = err.Error()
451 }
452 var protoResult protocol.ReloadResult
453 switch result {
454 case ApplyNoop:
455 protoResult = protocol.ReloadResult_NOOP
456 case ApplyApplied:
457 protoResult = protocol.ReloadResult_APPLIED
458 case ApplyRejected:
459 protoResult = protocol.ReloadResult_REJECTED
460 case ApplyRestartRequired:
461 protoResult = protocol.ReloadResult_RESTART_REQUIRED
462 }
463 return &protocol.IpcResponse{
464 Ok: result != ApplyRejected,
465 Response: &protocol.IpcResponse_Reload{Reload: &protocol.ReloadResponse{
466 Result: protoResult,
467 Message: msg,
468 }},
469 }
470}
471
472func handleTrace(n *Nylon, rw *bufio.ReadWriter) error {
473 if !n.DBG_trace_tc {

Callers 1

HandleNylonIPCFunction · 0.85

Calls 3

errResponseFunction · 0.85
ApplyCentralConfigMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected