Initial commit: Open sourcing all of the Maple Open Technologies code.
This commit is contained in:
commit
755d54a99d
2010 changed files with 448675 additions and 0 deletions
23
cloud/maplefile-backend/pkg/distributedmutex/provider.go
Normal file
23
cloud/maplefile-backend/pkg/distributedmutex/provider.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package distributedmutex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"codeberg.org/mapleopentech/monorepo/cloud/maplefile-backend/config"
|
||||
)
|
||||
|
||||
// ProvideDistributedMutexAdapter provides a distributed mutex adapter for Wire DI
|
||||
func ProvideDistributedMutexAdapter(cfg *config.Config, logger *zap.Logger) Adapter {
|
||||
// Create Redis client for distributed locking
|
||||
// Note: This is separate from the cache redis client
|
||||
redisClient := redis.NewClient(&redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", cfg.Cache.Host, cfg.Cache.Port),
|
||||
Password: cfg.Cache.Password,
|
||||
DB: cfg.Cache.DB,
|
||||
})
|
||||
|
||||
return NewAdapter(logger, redisClient)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue