Skip to content

Commit

Permalink
feat(go-nats): close streams
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Volosatovs <[email protected]>
  • Loading branch information
rvolosatovs committed Aug 20, 2024
1 parent 173426e commit 63e8f40
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions go/nats/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ func (w *paramWriter) Index(path ...uint32) (wrpc.IndexWriter, error) {
return nil, errors.New("indexing not supported yet")
}

func (w *paramWriter) Close() error {
if err := w.nc.Publish(w.tx, nil); err != nil {
return fmt.Errorf("failed to send shutdown message: %w", err)
}
return nil
}

type resultWriter struct {
nc *nats.Conn
tx string
Expand Down Expand Up @@ -197,6 +204,13 @@ func (w *resultWriter) WriteByte(b byte) error {
return nil
}

func (w *resultWriter) Close() error {
if err := w.nc.Publish(w.tx, nil); err != nil {
return fmt.Errorf("failed to send shutdown message: %w", err)
}
return nil
}

func (w *resultWriter) Index(path ...uint32) (wrpc.IndexWriter, error) {
return &resultWriter{nc: w.nc, tx: indexPath(w.tx, path...)}, nil
}
Expand Down

0 comments on commit 63e8f40

Please sign in to comment.