Skip to content

question. Reinitialization provide #349

@LazarenkoA

Description

@LazarenkoA

hello. I have such a code

container.Provide(func(clientCfg *config.Ignite) database.Db {
		ignite, err := database.NewIgnite(ctx, clientCfg)
		if err != nil {
			logger.Error(fmt.Errorf("container provide error: %w", err))
			return nil
		} else {
			return ignite
		}
	})

if the database is not available at the time of initialization, further calls will return nil

container.Invoke(func(ignite database.Db) error {
      //....
})

is it possible to make it so that when an error occurs atabase.NewIgnite(ctx, clientCfg) the container didn't remember the response, but the code went to container.Provide again?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions