Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 10, 2025
1 parent 76ccee4 commit ce703c3
Show file tree
Hide file tree
Showing 8 changed files with 388 additions and 40 deletions.
2 changes: 2 additions & 0 deletions storage_versioned_docs/version-minio_v0.x.x/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ type Storage interface {
- [S3](./s3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+S3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-s3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
- [ScyllaDB](./scylladb/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+scylladb%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-scylladb.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
- [SQLite3](./sqlite3/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Sqlite3%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-sqlite3.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
- [ClickHouse](./clickhouse/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+Clickhouse%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-clickhouse.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
- [Valkey](./valkey/README.md) <a href="https://github.com/gofiber/storage/actions?query=workflow%3A%22Tests+valkey%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/storage/test-valkey.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
123 changes: 123 additions & 0 deletions storage_versioned_docs/version-minio_v0.x.x/clickhouse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Clickhouse

A Clickhouse storage driver using [https://github.com/ClickHouse/clickhouse-go](https://github.com/ClickHouse/clickhouse-go).

### Table of Contents

- [Signatures](#signatures)
- [Installation](#installation)
- [Examples](#examples)
- [Config](#config)
- [Default Config](#default-config)

### Signatures

```go
func New(config ...Config) (*Storage, error)
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() *Session
```

### Installation

Clickhouse is supported on the latest two versions of Go:

Install the clickhouse implementation:
```bash
go get github.com/gofiber/storage/clickhouse
```

### Running the tests

This module uses [Testcontainers for Go](https://github.com/testcontainers/testcontainers-go/) to run integration tests, which will start a local instance of Clickhouse as a Docker container under the hood. To run the tests, you must have Docker (or another container runtime 100% compatible with the Docker APIs) installed on your machine.

### Local development

Before running this implementation, you must ensure a Clickhouse cluster is available.
For local development, we recommend using the Clickhouse Docker image; it contains everything
necessary for the client to operate correctly.

To start Clickhouse using Docker, issue the following:

```bash
docker run -d -p 9000:9000 --name some-clickhouse-server --ulimit nofile=262144:262144 clickhouse/clickhouse-server
```

After running this command you're ready to start using the storage and connecting to the database.

### Examples

You can use the following options to create a clickhouse storage driver:
```go
import "github.com/gofiber/storage/clickhouse"

// Initialize default config, to connect to localhost:9000 using the memory engine and with a clean table.
store, err := clickhouse.New(clickhouse.Config{
Host: "localhost",
Port: 9000,
Clean: true,
})

// Initialize custom config to connect to a different host/port and use custom engine and with clean table.
store, err := clickhouse.New(clickhouse.Config{
Host: "some-ip-address",
Port: 9000,
Engine: clickhouse.MergeTree,
Clean: true,
})

// Initialize to connect with TLS enabled with your own tls.Config and with clean table.
tlsConfig := config := &tls.Config{...}

store, err := clickhouse.New(clickhouse.Config{
Host: "some-ip-address",
Port: 9000,
Clean: true,
TLSConfig: tlsConfig,
})
```

### Config

```go
// Config defines configuration options for Clickhouse connection.
type Config struct {
// The host of the database. Ex: 127.0.0.1
Host string
// The port where the database is supposed to listen to. Ex: 9000
Port int
// The database that the connection should authenticate from
Database string
// The username to be used in the authentication
Username string
// The password to be used in the authentication
Password string
// The name of the table that will store the data
Table string
// The engine that should be used in the table
Engine string
// Should start a clean table, default false
Clean bool
// TLS configuration, default nil
TLSConfig *tls.Config
// Should the connection be in debug mode, default false
Debug bool
// The function to use with the debug config, default print function. It only works when debug is true
Debugf func(format string, v ...any)
}
```

### Default Config

```go
var DefaultConfig = Config{
Host: "localhost",
Port: 9000,
Engine: "Memory",
Clean: false,
}
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Coherence
<!-- Copyright © 2023, Oracle and/or its affiliates. -->
<!-- Copyright © 2023, 2025 Oracle and/or its affiliates. -->
A Coherence storage driver using [https://github.com/oracle/coherence-go-client](https://github.com/oracle/coherence-go-client).

### Table of Contents
Expand Down Expand Up @@ -35,10 +35,10 @@ necessary for the client to operate correctly.
To start a Coherence cluster using Docker, issue the following:

```bash
docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:22.06.7
docker run -d -p 1408:1408 ghcr.io/oracle/coherence-ce:24.09
```

See the documentation [here](https://pkg.go.dev/github.com/oracle/coherence-go-client/coherence#hdr-Obtaining_a_Session) on connection options
See the documentation [here](https://pkg.go.dev/github.com/oracle/coherence-go-client/[email protected]/coherence#hdr-Obtaining_a_Session) on connection options
when creating a Coherence session.

### Examples
Expand Down
5 changes: 5 additions & 0 deletions storage_versioned_docs/version-minio_v0.x.x/minio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ type Config struct {
// Optional. Default is false
Reset bool

// The maximum number of times requests that encounter retryable failures should be attempted.
// Optional. Default is 10, same as the MinIO client.
MaxRetry int

// Credentials Minio access key and Minio secret key.
// Need to be defined
Credentials Credentials
Expand Down Expand Up @@ -124,6 +128,7 @@ var ConfigDefault = Config{
Token: "",
Secure: false,
Reset: false,

Credentials: Credentials{},
GetObjectOptions: minio.GetObjectOptions{},
PutObjectOptions: minio.PutObjectOptions{},
Expand Down
66 changes: 31 additions & 35 deletions storage_versioned_docs/version-minio_v0.x.x/nats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ title: Nats

A NATS Key/Value storage driver.

**Note: Requires Go 1.20 and above**
## Note: Requires Go 1.20 and above

### Table of Contents

Expand Down Expand Up @@ -57,60 +57,56 @@ Import the storage package.
import "github.com/gofiber/storage/nats"
```

You can use the following possibilities to create a storage:
You can use the following options to create a storage driver:

```go
// Initialize default config
store := nats.New()

// Initialize custom config
store := nats.New(Config{
URLs: "nats://127.0.0.1:4443",
NatsOptions: []nats.Option{
nats.MaxReconnects(2),
// Enable TLS by specifying RootCAs
nats.RootCAs("./testdata/certs/ca.pem"),
},
KeyValueConfig: jetstream.KeyValueConfig{
Bucket: "test",
Storage: jetstream.MemoryStorage,
},
URLs: "nats://127.0.0.1:4443",
NatsOptions: []nats.Option{
nats.MaxReconnects(2),
// Enable TLS by specifying RootCAs
nats.RootCAs("./testdata/certs/ca.pem"),
},
KeyValueConfig: jetstream.KeyValueConfig{
Bucket: "test",
Storage: jetstream.MemoryStorage,
},
})
```

### Config

```go
type Config struct {
// Nats URLs, default "nats://127.0.0.1:4222". Can be comma separated list for multiple servers
URLs string
// Nats connection options. See nats_test.go for an example of how to use this.
NatsOptions []nats.Option
// Nats connection name
ClientName string
// Nats context
Context context.Context
// Nats key value config
KeyValueConfig jetstream.KeyValueConfig
// Logger. Using Fiber AllLogger interface for adapting the various log libraries.
Logger log.AllLogger
// Use the Logger for nats events, default: false
Verbose bool
// Wait for connection to be established, default: 100ms
WaitForConnection time.Duration
// Nats URLs, default "nats://127.0.0.1:4222". Can be comma separated list for multiple servers
URLs string
// Nats connection options. See nats_test.go for an example of how to use this.
NatsOptions []nats.Option
// Nats connection name
ClientName string
// Nats context
Context context.Context
// Nats key value config
KeyValueConfig jetstream.KeyValueConfig
// Wait for connection to be established, default: 100ms
WaitForConnection time.Duration
}
```

### Default Config

```go
var ConfigDefault = Config{
URLs: nats.DefaultURL,
Context: context.Background(),
ClientName: "fiber_storage",
KeyValueConfig: jetstream.KeyValueConfig{
Bucket: "fiber_storage",
},
WaitForConnection: 100 * time.Millisecond,
URLs: nats.DefaultURL,
Context: context.Background(),
ClientName: "fiber_storage",
KeyValueConfig: jetstream.KeyValueConfig{
Bucket: "fiber_storage",
},
WaitForConnection: 100 * time.Millisecond,
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ title: Postgres

A Postgres storage driver using [jackc/pgx](https://github.com/jackc/pgx).

**Note: Requires Go 1.19 and above**
**Note: Requires Go 1.20 and above**

### Table of Contents
- [Signatures](#signatures)
Expand Down
Loading

0 comments on commit ce703c3

Please sign in to comment.