Skip to content

Commit 2bec7a7

Browse files
1 parent b77e18e commit 2bec7a7

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

docs/storage/nats/README.md

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ title: Nats
1212

1313
A NATS Key/Value storage driver.
1414

15-
**Note: Requires Go 1.20 and above**
15+
## Note: Requires Go 1.20 and above
1616

1717
### Table of Contents
1818

@@ -57,60 +57,56 @@ Import the storage package.
5757
import "github.com/gofiber/storage/nats"
5858
```
5959

60-
You can use the following possibilities to create a storage:
60+
You can use the following options to create a storage driver:
6161

6262
```go
6363
// Initialize default config
6464
store := nats.New()
6565

6666
// Initialize custom config
6767
store := nats.New(Config{
68-
URLs: "nats://127.0.0.1:4443",
69-
NatsOptions: []nats.Option{
70-
nats.MaxReconnects(2),
71-
// Enable TLS by specifying RootCAs
72-
nats.RootCAs("./testdata/certs/ca.pem"),
73-
},
74-
KeyValueConfig: jetstream.KeyValueConfig{
75-
Bucket: "test",
76-
Storage: jetstream.MemoryStorage,
77-
},
68+
URLs: "nats://127.0.0.1:4443",
69+
NatsOptions: []nats.Option{
70+
nats.MaxReconnects(2),
71+
// Enable TLS by specifying RootCAs
72+
nats.RootCAs("./testdata/certs/ca.pem"),
73+
},
74+
KeyValueConfig: jetstream.KeyValueConfig{
75+
Bucket: "test",
76+
Storage: jetstream.MemoryStorage,
77+
},
7878
})
7979
```
8080

8181
### Config
8282

8383
```go
8484
type Config struct {
85-
// Nats URLs, default "nats://127.0.0.1:4222". Can be comma separated list for multiple servers
86-
URLs string
87-
// Nats connection options. See nats_test.go for an example of how to use this.
88-
NatsOptions []nats.Option
89-
// Nats connection name
90-
ClientName string
91-
// Nats context
92-
Context context.Context
93-
// Nats key value config
94-
KeyValueConfig jetstream.KeyValueConfig
95-
// Logger. Using Fiber AllLogger interface for adapting the various log libraries.
96-
Logger log.AllLogger
97-
// Use the Logger for nats events, default: false
98-
Verbose bool
99-
// Wait for connection to be established, default: 100ms
100-
WaitForConnection time.Duration
85+
// Nats URLs, default "nats://127.0.0.1:4222". Can be comma separated list for multiple servers
86+
URLs string
87+
// Nats connection options. See nats_test.go for an example of how to use this.
88+
NatsOptions []nats.Option
89+
// Nats connection name
90+
ClientName string
91+
// Nats context
92+
Context context.Context
93+
// Nats key value config
94+
KeyValueConfig jetstream.KeyValueConfig
95+
// Wait for connection to be established, default: 100ms
96+
WaitForConnection time.Duration
10197
}
10298
```
10399

104100
### Default Config
105101

106102
```go
107103
var ConfigDefault = Config{
108-
URLs: nats.DefaultURL,
109-
Context: context.Background(),
110-
ClientName: "fiber_storage",
111-
KeyValueConfig: jetstream.KeyValueConfig{
112-
Bucket: "fiber_storage",
113-
},
114-
WaitForConnection: 100 * time.Millisecond,
104+
URLs: nats.DefaultURL,
105+
Context: context.Background(),
106+
ClientName: "fiber_storage",
107+
KeyValueConfig: jetstream.KeyValueConfig{
108+
Bucket: "fiber_storage",
109+
},
110+
WaitForConnection: 100 * time.Millisecond,
115111
}
116112
```

0 commit comments

Comments
 (0)