@@ -56,12 +56,12 @@ type ProcessHandler interface {
56
56
ctx context.Context ,
57
57
timeout time.Duration ,
58
58
) (int , error )
59
- ReadFile (file string ) ([]byte , error )
59
+ readFile (file string ) ([]byte , error )
60
60
Kill (pid int ) error
61
61
}
62
62
63
63
type ProcessHandlerImpl struct {
64
- ReadFile ReadFileFunc
64
+ readFile ReadFileFunc
65
65
checkFile CheckFileFunc
66
66
}
67
67
@@ -130,7 +130,7 @@ func (m *ManagerImpl) Reload(ctx context.Context, configVersion int) error {
130
130
}
131
131
132
132
childProcFile := fmt .Sprintf (childProcPathFmt , pid )
133
- previousChildProcesses , err := m .processHandler .ReadFile (childProcFile )
133
+ previousChildProcesses , err := m .processHandler .readFile (childProcFile )
134
134
if err != nil {
135
135
return err
136
136
}
@@ -193,11 +193,16 @@ func (m *ManagerImpl) GetUpstreams() (ngxclient.Upstreams, error) {
193
193
return * upstreams , nil
194
194
}
195
195
196
- type NewProcessHandlerImpl struct {
197
- checkFile func (file string ) (string , error )
196
+ func NewProcessHandlerImpl (readFile ReadFileFunc , checkFile CheckFileFunc ) * ProcessHandlerImpl {
197
+ ph := & ProcessHandlerImpl {
198
+ readFile : readFile ,
199
+ checkFile : checkFile ,
200
+ }
201
+
202
+ return ph
198
203
}
199
204
200
- func (p * NewProcessHandlerImpl ) FindMainProcess (
205
+ func (p * ProcessHandlerImpl ) FindMainProcess (
201
206
ctx context.Context ,
202
207
timeout time.Duration ,
203
208
) (int , error ) {
@@ -222,7 +227,7 @@ func (p *NewProcessHandlerImpl) FindMainProcess(
222
227
return 0 , err
223
228
}
224
229
225
- content , err := p .ReadFile (PidFile )
230
+ content , err := p .readFile (PidFile )
226
231
if err != nil {
227
232
return 0 , err
228
233
}
@@ -235,10 +240,10 @@ func (p *NewProcessHandlerImpl) FindMainProcess(
235
240
return pid , nil
236
241
}
237
242
238
- func (p * NewProcessHandlerImpl ) ReadFile (file string ) ([]byte , error ) {
243
+ func (p * ProcessHandlerImpl ) ReadFile (file string ) ([]byte , error ) {
239
244
return p .ReadFile (file )
240
245
}
241
246
242
- func (p * NewProcessHandlerImpl ) Kill (pid int ) error {
247
+ func (p * ProcessHandlerImpl ) Kill (pid int ) error {
243
248
return syscall .Kill (pid , syscall .SIGHUP )
244
249
}
0 commit comments