some renaming

This commit is contained in:
Egor Aristov 2026-03-28 14:47:47 +03:00
parent c242c72f3d
commit 4010408b08
2 changed files with 21 additions and 21 deletions

View File

@ -27,17 +27,17 @@ type pendingCall struct {
} }
type ipcCommon struct { type ipcCommon struct {
localApis map[string]any localApis map[string]any
socketPath string socketPath string
conn net.Conn conn net.Conn
errCh chan error errCh chan error
nextId int64 nextId int64
pendingCalls map[int64]*pendingCall pendingCalls map[int64]*pendingCall
processingCalls atomic.Int64 processingIncomingCalls atomic.Int64
stopRequested atomic.Bool stopRequested atomic.Bool
mu sync.Mutex mu sync.Mutex
writeMu sync.Mutex writeMu sync.Mutex
ctx context.Context ctx context.Context
} }
func (ipc *ipcCommon) readConn() { func (ipc *ipcCommon) readConn() {
@ -50,17 +50,17 @@ func (ipc *ipcCommon) readConn() {
ipc.raiseErr(fmt.Errorf("unmarshal message: %w", err)) ipc.raiseErr(fmt.Errorf("unmarshal message: %w", err))
break break
} }
ipc.processMsg(msg) ipc.handleIncomingMsg(msg)
} }
if err := scn.Err(); err != nil { if err := scn.Err(); err != nil {
ipc.raiseErr(err) ipc.raiseErr(err)
} }
} }
func (ipc *ipcCommon) processMsg(msg Message) { func (ipc *ipcCommon) handleIncomingMsg(msg Message) {
switch msg.Type { switch msg.Type {
case MsgCall: case MsgCall:
go ipc.handleCall(msg) go ipc.handleIncomingCall(msg)
case MsgResponse: case MsgResponse:
ipc.handleResponse(msg) ipc.handleResponse(msg)
} }
@ -83,13 +83,13 @@ func (ipc *ipcCommon) sendMsg(msg Message) error {
return nil return nil
} }
func (ipc *ipcCommon) handleCall(msg Message) { func (ipc *ipcCommon) handleIncomingCall(msg Message) {
if ipc.stopRequested.Load() { if ipc.stopRequested.Load() {
return return
} }
ipc.processingCalls.Add(1) ipc.processingIncomingCalls.Add(1)
defer ipc.processingCalls.Add(-1) defer ipc.processingIncomingCalls.Add(-1)
defer func() { defer func() {
if err := recover(); err != nil { if err := recover(); err != nil {
@ -126,12 +126,12 @@ func (ipc *ipcCommon) handleCall(msg Message) {
results = append(results, resVal.Interface()) results = append(results, resVal.Interface())
} }
var resErr error var resultError error
if !errResultVals.IsNil() { if !errResultVals.IsNil() {
resErr = errResultVals.Interface().(error) resultError = errResultVals.Interface().(error)
} }
ipc.sendResponse(msg.Id, results, resErr) ipc.sendResponse(msg.Id, results, resultError)
} }
func (ipc *ipcCommon) findMethod(methodName string) (reflect.Value, error) { func (ipc *ipcCommon) findMethod(methodName string) (reflect.Value, error) {

View File

@ -111,7 +111,7 @@ func (p *ParentIPC) Stop() error {
if hasPending { if hasPending {
return fmt.Errorf("there are calls pending") return fmt.Errorf("there are calls pending")
} }
if p.processingCalls.Load() > 0 { if p.processingIncomingCalls.Load() > 0 {
return fmt.Errorf("there are calls processing") return fmt.Errorf("there are calls processing")
} }
p.stopRequested.Store(true) p.stopRequested.Store(true)