From 63e8f4058addc62fa61c575e259cb759e0712fee Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Tue, 20 Aug 2024 16:38:57 +0200 Subject: [PATCH] feat(go-nats): close streams Signed-off-by: Roman Volosatovs --- go/nats/client.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/go/nats/client.go b/go/nats/client.go index df362506..ad505266 100644 --- a/go/nats/client.go +++ b/go/nats/client.go @@ -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 @@ -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 }