Documentation
¶
Overview ¶
Package factory provides configuration-based creation of distributed locks. It integrates with the config.DistributionLock configuration to create DLock instances with their respective providers.
Example:
f := factory.New(factory.WithNatsConn(conn), factory.WithLogger(logger))
dl, err := f.CreateDLockFromConfig(ctx, cfg)
if err != nil {
log.Fatal(err)
}
defer dl.Close(ctx)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory struct {
corefactory.Base
// contains filtered or unexported fields
}
Factory creates distributed locks from configuration.
func (*Factory) CreateDLockFromConfig ¶
func (f *Factory) CreateDLockFromConfig(ctx context.Context, cfg *config.DistributionLock) (*dlock.DLock, error)
CreateDLockFromConfig creates a DLock from configuration.
func (*Factory) CreateNatsDLockFromConfig ¶
func (f *Factory) CreateNatsDLockFromConfig(ctx context.Context, cfg *config.DistributionLockNats) (*dlock.DLock, error)
CreateNatsDLockFromConfig creates a DLock with NATS provider.
func (*Factory) CreateNoopDLock ¶
CreateNoopDLock creates a DLock with no-op provider for testing.
Click to show internal directories.
Click to hide internal directories.