Go Fiber 한글 공식 문서
  • 🙇‍♀️안녕하세요
  • 🏠Home
    • 👋Welcome
    • 📁API
      • 📦Fiber
      • 🚀App
      • 🧠Ctx
      • 📋Constants
      • 🌎Client
      • 📃Log
      • 🧬Middleware
        • Adaptor
        • BasicAuth
        • Cache
        • Compress
        • CORS
        • CSRF
        • EarlyData
        • Encrypt Cookie
        • EnvVar
        • ETag
        • ExpVar
        • Favicon
        • FileSystem
        • Health Check
        • Helmet
        • Idempotency
        • Keyauth
        • Limiter
        • Logger
        • Monitor
        • Pprof
        • Proxy
        • Recover
        • Redirect
        • RequestID
        • Rewrite
        • Session
        • Skip
        • Timeout
    • 📁Guide
      • 🔌Routing
      • 🎭Grouping
      • 📝Templates
      • 🐛Error Handling
      • 🔎Validation
      • 🎣Hooks
      • ⚡Make Fiber Faster
    • 📁Extra
      • 🤔FAQ
      • 📊Benchmarks
  • 🧩Extra
    • 🧬Contrip
      • 👋Welcome
      • Casbin
      • Fgprof
      • Fiberi18n
      • Fibernewrelic
      • Fibersentry
      • Fiberzap
      • Fiberzerolog
      • JWT
      • LoadShed
      • Opafiber
      • Otelfiber
        • Example
      • Paseto
      • README
      • Swagger
      • Websocket
    • 📦Storage
      • 👋Welcome
      • ArangoDB
      • Azure Blob
      • Badger
      • Bbolt
      • Coherence
      • Couchbase
      • DynamoDB
      • Etcd
      • Memcache
      • Memory
      • Minio
      • MongoDB
      • MSSQL
      • MySQL
      • Nats
      • Pebble
      • Postgres
      • Redis
      • Ristretto
      • Rueidis
      • S3
      • ScyllaDb
      • SQLite3
    • 📃Template
      • 👋Welcome
      • Ace
      • Amber
      • Django
      • Handlebars
      • HTML
        • Golang Templates Cheatsheet
      • Jet
      • Mustache
      • Pug
      • Slim
Powered by GitBook
On this page
  • Table of Contents
  • Signatures
  • Installation
  • Examples
  • Config
  • Default Config
  1. Extra
  2. Storage

Etcd

PreviousDynamoDBNextMemcache

Last updated 1 year ago


를 사용하는 Etcd 스토리지 드라이버입니다.

참고: Go 1.19 이상이 필요합니다

Table of Contents

  • Signatures

  • Installation

  • Examples

  • Config

  • Default Config

Signatures

func New(config ...Config) *Storage

func (s *Storage) Get(key string) ([]byte, error)

func (s *Storage) Set(key string, val []byte, exp time.Duration) error

func (s *Storage) Delete(key string) error

func (s *Storage) Reset() error

func (s *Storage) Close() error

func (s *Storage) Conn() clientv3.Client

Installation

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

그런 다음 etcd 구현을 설치하세요:

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

Examples

스토리지 패키지를 임포트하세요.

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

다음과 같은 방법으로 스토리지를 생성할 수 있습니다:

// 기본 설정으로 초기화
store := etcd.New()

// 사용자 정의 설정으로 초기화
store := etcd.New(Config{
  Endpoints: []string{"localhost:2379"},
})

Config

type Config struct {
    // Endpoints는 URL 목록입니다.
    Endpoints []string

    // DialTimeout은 연결 설정 실패 시 타임아웃입니다.
    DialTimeout time.Duration

    // Username은 인증을 위한 사용자 이름입니다.
    Username string

    // Password는 인증을 위한 비밀번호입니다.
    Password string

    // TLS는 클라이언트 보안 자격 증명을 보유합니다(있는 경우).
    TLS *tls.Config
}

Default Config

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

Etcd는 모듈 지원을 통해 의 최신 2개 버전에서 테스트됩니다. 아직 모듈을 초기화하지 않았다면 먼저 초기화하세요:

🧩
📦
Go versions
etcd-io/etcd