@@ -136,22 +136,6 @@ type natsStoredMsg struct {
136
136
Sequence uint64 `json:"seq"`
137
137
}
138
138
139
- // EventStoreConfig is a subset of the nats.StreamConfig for the purpose of creating
140
- // purpose-built streams for an event store.
141
- type EventStoreConfig struct {
142
- // Description associated with the event store.
143
- Description string
144
- // Subjects to associated with the stream. If not specified, it will default to
145
- // the name plus the variadic wildcard, e.g. "orders.>"
146
- Subjects []string
147
- // Storage for the stream.
148
- Storage nats.StorageType
149
- // Replicas of the stream.
150
- Replicas int
151
- // Placement of the stream replicas.
152
- Placement * nats.Placement
153
- }
154
-
155
139
// EventStore provides event store semantics over a NATS stream.
156
140
type EventStore struct {
157
141
name string
@@ -410,41 +394,27 @@ func (s *EventStore) Evolve(ctx context.Context, subject string, model Evolver,
410
394
411
395
// Create creates the event store given the configuration. The stream
412
396
// name is the name of the store and the subjects default to "{name}}.>".
413
- func (s * EventStore ) Create (config * EventStoreConfig ) error {
397
+ func (s * EventStore ) Create (config * nats. StreamConfig ) error {
414
398
if config == nil {
415
- config = & EventStoreConfig {}
399
+ config = & nats. StreamConfig {}
416
400
}
401
+ config .Name = s .name
417
402
418
- subjects := config .Subjects
419
- if len (subjects ) == 0 {
420
- subjects = []string {fmt .Sprintf ("%s.>" , s .name )}
403
+ if len (config .Subjects ) == 0 {
404
+ config .Subjects = []string {fmt .Sprintf ("%s.>" , s .name )}
421
405
}
422
406
423
- _ , err := s .rt .js .AddStream (& nats.StreamConfig {
424
- Name : s .name ,
425
- Description : config .Description ,
426
- Subjects : subjects ,
427
- Storage : config .Storage ,
428
- Replicas : config .Replicas ,
429
- Placement : config .Placement ,
430
- DenyDelete : true ,
431
- DenyPurge : true ,
432
- })
407
+ _ , err := s .rt .js .AddStream (config )
433
408
return err
434
409
}
435
410
436
411
// Update updates the event store configuration.
437
- func (s * EventStore ) Update (config * EventStoreConfig ) error {
438
- _ , err := s .rt .js .UpdateStream (& nats.StreamConfig {
439
- Name : s .name ,
440
- Description : config .Description ,
441
- Subjects : config .Subjects ,
442
- Storage : config .Storage ,
443
- Replicas : config .Replicas ,
444
- Placement : config .Placement ,
445
- DenyDelete : true ,
446
- DenyPurge : true ,
447
- })
412
+ func (s * EventStore ) Update (config * nats.StreamConfig ) error {
413
+ if config == nil {
414
+ config = & nats.StreamConfig {}
415
+ }
416
+ config .Name = s .name
417
+ _ , err := s .rt .js .UpdateStream (config )
448
418
return err
449
419
}
450
420
0 commit comments