You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: relay.go
    path of file: ./repos/plumber/backends/nats-streaming
    
    the code of the file until where you have to start completion: package nats_streaming

import (
	"context"
	"time"

	"github.com/nats-io/stan.go"
	pb2 "github.com/nats-io/stan.go/pb"
	"github.com/pkg/errors"

	"github.com/batchcorp/plumber-schemas/build/go/protos/opts"
	"github.com/batchcorp/plumber-schemas/build/go/protos/r
    
func (n *NatsStreaming) Relay(ctx context.Context, relayOpts *opts.RelayOptions, relayCh chan interface{}, errorCh chan<- *records.ErrorRecord) error {
	if err := validateRelayOptions(relayOpts); err != nil {
		return errors.Wrap(err, "invalid read options")
	}

	var subFunc = func(msg *stan.Msg) {
		prometheus.Incr("nats-streaming-relay-consumer", 1)
		relayCh <- &types.RelayMessage{
			Value: msg,
			Options: &types.RelayMessageOptions{
				Channel: relayOpts.NatsStreaming.Args.Channel,
			},
		}
	}

	subOptions, err := n.getRelayReadOptions(relayOpts)
	if err != nil {
		return errors.Wrap(err, "unable to read from nats-streaming")
	}

	sub, err := n.stanClient.Subscribe(relayOpts.NatsStreaming.Args.Channel, subFunc, subOptions...)
	if err != nil {
		return errors.Wrap(err, "unable to create subscription")
	}

	defer sub.Unsubscribe()

	<-ctx.Done()
	n.log.Debug("Received shutdown signal, exiting relayer")

	return nil
}