Skip to content

Connect() function in worker_manager.go should return error instead of leading to termination of the program #3

@waliaashish85

Description

@waliaashish85

log.Fatal() calls os.Exit(1)
https://github.com/Sirupsen/logrus/blob/44512f0d08f7f81a75f5b04a2cb6d81ed25431ca/logger.go#L152

Therefore, the program would stop executing after calling log.Fatal()

// Connect to broker. Returns an error if connection fails.
func (manager *workerManager) Connect() error {
    broker, err := broker.NewBroker(manager.brokerURL)
    if err != nil {
        log.Fatal("Failed to connect to broker: ", err)
        return err
    }

    log.Debug("Connected to broker: ", manager.brokerURL)
    manager.broker = broker
    return nil
}

Possible Resolution:-
Use log.Error()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions