Files
storage/etcd
dependabot[bot] 3ce1412da7 chore(deps): bump the docker-modules group across 1 directory with 2 updates
Bumps the docker-modules group with 2 updates in the /etcd directory: [github.com/docker/docker](https://github.com/docker/docker) and [github.com/moby/term](https://github.com/moby/term).


Updates `github.com/docker/docker` from 28.5.1+incompatible to 28.5.2+incompatible
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v28.5.1...v28.5.2)

Updates `github.com/moby/term` from 0.5.0 to 0.5.2
- [Commits](https://github.com/moby/term/compare/v0.5.0...v0.5.2)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-version: 28.5.2+incompatible
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: docker-modules
- dependency-name: github.com/moby/term
  dependency-version: 0.5.2
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: docker-modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-28 07:18:57 +00:00
..
2023-07-03 23:59:48 +03:00
2025-11-24 18:17:50 +01:00
2025-07-06 16:07:06 +03:00

id, title
id title
etcd Etcd

Release Discord Test

A Etcd storage driver using etcd-io/etcd.

Table of Contents

Signatures

func New(config ...Config) *Storage
func (s *Storage) Get(key string) ([]byte, error)
func (s *Storage) GetWithContext(ctx context.Context, key string) ([]byte, error)
func (s *Storage) Set(key string, val []byte, exp time.Duration) error
func (s *Storage) SetWithContext(ctx context.Context, key string, val []byte, exp time.Duration) error
func (s *Storage) Delete(key string) error
func (s *Storage) DeleteWithContext(ctx context.Context, key string) error
func (s *Storage) Reset() error
func (s *Storage) ResetWithContext(ctx context.Context) error
func (s *Storage) Close() error
func (s *Storage) Conn() *clientv3.Client

Installation

Etcd is tested on the 2 last Go versions with support for modules. So make sure to initialize one first if you didn't do that yet:

go mod init github.com/<user>/<repo>

And then install the etcd implementation:

go get github.com/gofiber/storage/etcd/v2

Examples

Import the storage package.

import "github.com/gofiber/storage/etcd/v2"

You can use the following possibilities to create a storage:

// Initialize default config
store := etcd.New()

// Initialize custom config
store := etcd.New(Config{
    Endpoints: []string{"localhost:2379"},
})

Config

type Config struct {
    // Endpoints is a list of URLs.
    Endpoints   []string
    // DialTimeout is the timeout for failing to establish a connection.
    DialTimeout time.Duration
    // Username is a username for authentication.
    Username    string
    // Password is a password for authentication.
    Password    string
	// TLS holds the client secure credentials, if any.
	TLS *tls.Config
}

Default Config

var ConfigDefault = Config{
    Endpoints:   []string{"localhost:2379"},
    DialTimeout: 2 * time.Second,
    Username:    "",
    Password:    "",
    TLS:         nil,
}