// 기본 설정으로 초기화
store := nats.New()
// 사용자 정의 설정으로 초기화
store := nats.New(Config{
URLs: "nats://127.0.0.1:4443",
NatsOptions: []nats.Option{
nats.MaxReconnects(2),
// RootCA를 지정하여 TLS 활성화
nats.RootCAs("./testdata/certs/ca.pem"),
},
KeyValueConfig: jetstream.KeyValueConfig{
Bucket: "test",
Storage: jetstream.MemoryStorage,
},
})
Config
type Config struct {
// Nats URLs, 기본값 "nats://127.0.0.1:4222". 여러 서버를 위해 쉼표로 구분된 목록일 수 있음
URLs string
// Nats 연결 옵션. 사용 예시는 nats_test.go 참고
NatsOptions []nats.Option
// Nats 연결 이름
ClientName string
// Nats 컨텍스트
Context context.Context
// Nats key value 설정
KeyValueConfig jetstream.KeyValueConfig
// Logger. Fiber AllLogger 인터페이스를 사용하여 다양한 로그 라이브러리 적용 가능
Logger log.AllLogger
// Nats 이벤트에 Logger 사용 여부, 기본값: false
Verbose bool
// 연결이 설정될 때까지 대기, 기본값: 100ms
WaitForConnection time.Duration
}