mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-27 17:50:53 +01:00
feat: enhance gRPC client with state management and reconnection logic
- Introduced state management in GrpcClient to monitor and handle connection states effectively. - Added a reconnect channel and a state monitoring goroutine to facilitate automatic reconnections on state changes. - Updated the connect method to initiate a reconnection loop upon connection loss. - Enhanced logging for connection state changes and errors during connection attempts. - Refactored tests to ensure proper initialization of gRPC client and server, improving test reliability and coverage.
This commit is contained in:
@@ -75,14 +75,14 @@ type Runner struct {
|
||||
|
||||
// Init initializes the task runner by updating the task status and establishing gRPC connections
|
||||
func (r *Runner) Init() (err error) {
|
||||
// wait for grpc client ready
|
||||
client2.GetGrpcClient().WaitForReady()
|
||||
|
||||
// update task
|
||||
if err := r.updateTask("", nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// wait for grpc client ready
|
||||
client2.GetGrpcClient().WaitForReady()
|
||||
|
||||
// grpc task service stream client
|
||||
if err := r.initConnection(); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user