github.com/argoproj/argo-events@v1.9.1/eventbus/stan/eventsource/source_conn.go (about) 1 package eventsource 2 3 import ( 4 "context" 5 "fmt" 6 7 eventbuscommon "github.com/argoproj/argo-events/eventbus/common" 8 stanbase "github.com/argoproj/argo-events/eventbus/stan/base" 9 ) 10 11 type STANSourceConn struct { 12 *stanbase.STANConnection 13 eventSourceName string 14 subject string 15 } 16 17 func (n *STANSourceConn) Publish(ctx context.Context, 18 msg eventbuscommon.Message) error { 19 if n == nil { 20 return fmt.Errorf("Publish() failed; JetstreamSourceConn is nil") 21 } 22 return n.STANConn.Publish(n.subject, msg.Body) 23 } 24 25 func (conn *STANSourceConn) IsClosed() bool { 26 return conn == nil || conn.STANConnection.IsClosed() 27 } 28 29 func (conn *STANSourceConn) Close() error { 30 if conn == nil { 31 return fmt.Errorf("can't close STAN source connection, STANSourceConn is nil") 32 } 33 return conn.STANConnection.Close() 34 }