github.com/argoproj/argo-events@v1.9.1/eventbus/stan/eventsource/source_stan.go (about)

     1  package eventsource
     2  
     3  import (
     4  	eventbuscommon "github.com/argoproj/argo-events/eventbus/common"
     5  	stanbase "github.com/argoproj/argo-events/eventbus/stan/base"
     6  	"go.uber.org/zap"
     7  )
     8  
     9  type SourceSTAN struct {
    10  	*stanbase.STAN
    11  	eventSourceName string
    12  	subject         string
    13  }
    14  
    15  func NewSourceSTAN(url, clusterID, eventSourceName string, subject string, auth *eventbuscommon.Auth, logger *zap.SugaredLogger) *SourceSTAN {
    16  	return &SourceSTAN{
    17  		stanbase.NewSTAN(url, clusterID, auth, logger),
    18  		eventSourceName,
    19  		subject,
    20  	}
    21  }
    22  
    23  func (n *SourceSTAN) Initialize() error {
    24  	return nil
    25  }
    26  
    27  func (n *SourceSTAN) Connect(clientID string) (eventbuscommon.EventSourceConnection, error) {
    28  	conn, err := n.MakeConnection(clientID)
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  
    33  	return &STANSourceConn{conn, n.eventSourceName, n.subject}, nil
    34  }