draincloud-core/internal/config/external_provider/natskv/nats.go

31 lines
592 B
Go
Raw Normal View History

2024-11-29 05:23:56 +00:00
package natskv
import (
"context"
"git.optclblast.xyz/draincloud/draincloud-core/internal/logger"
"github.com/nats-io/nats.go/jetstream"
)
type Provider struct {
cc jetstream.KeyValue
}
func New(
ctx context.Context,
js jetstream.JetStream,
) *Provider {
kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{
Bucket: "rtc",
Description: "Real Time Config",
Storage: jetstream.FileStorage,
Replicas: 2,
Compression: true,
})
if err != nil {
logger.Fatal(ctx, "[natskv][New] failed to initialize rtc", logger.Err(err))
}
return &Provider{cc: kv}
}