Beispiel #1
0
// Set up link fields and open the proton.Link
func localLink(sn *session, isSender bool, setting ...LinkOption) (link, error) {
	l := link{
		session:  sn,
		isSender: isSender,
		capacity: 1,
		prefetch: false,
		done:     make(chan struct{}),
	}
	for _, set := range setting {
		set(&l)
	}
	if l.linkName == "" {
		l.linkName = l.session.connection.container.nextLinkName()
	}
	if l.IsSender() {
		l.eLink = l.session.eSession.Sender(l.linkName)
	} else {
		l.eLink = l.session.eSession.Receiver(l.linkName)
	}
	if l.eLink.IsNil() {
		l.err.Set(fmt.Errorf("cannot create link %s", l))
		return l, l.err.Get()
	}
	l.eLink.Source().SetAddress(l.source)
	l.eLink.Target().SetAddress(l.target)
	l.eLink.SetSndSettleMode(proton.SndSettleMode(l.sndSettle))
	l.eLink.SetRcvSettleMode(proton.RcvSettleMode(l.rcvSettle))
	l.str = l.eLink.String()
	l.eLink.Open()
	return l, nil
}
Beispiel #2
0
// Open a link and return the linkSettings.
func makeLocalLink(sn *session, isSender bool, setting ...LinkOption) (linkSettings, error) {
	l := linkSettings{
		isSender: isSender,
		capacity: 1,
		prefetch: false,
		session:  sn,
	}
	for _, set := range setting {
		set(&l)
	}
	if l.linkName == "" {
		l.linkName = l.session.connection.container.nextLinkName()
	}
	if l.IsSender() {
		l.pLink = l.session.pSession.Sender(l.linkName)
	} else {
		l.pLink = l.session.pSession.Receiver(l.linkName)
	}
	if l.pLink.IsNil() {
		return l, fmt.Errorf("cannot create link %s", l.pLink)
	}
	l.pLink.Source().SetAddress(l.source)
	l.pLink.Target().SetAddress(l.target)
	l.pLink.SetSndSettleMode(proton.SndSettleMode(l.sndSettle))
	l.pLink.SetRcvSettleMode(proton.RcvSettleMode(l.rcvSettle))
	l.pLink.Open()
	return l, nil
}
Beispiel #3
0
// Set local end of the link to match LinkSettings.
func (l *link) setSettings() {
	l.eLink.Source().SetAddress(l.settings.Source)
	l.eLink.Target().SetAddress(l.settings.Target)
	l.eLink.SetSndSettleMode(proton.SndSettleMode(l.settings.SndSettleMode))
	l.eLink.SetRcvSettleMode(proton.RcvSettleMode(l.settings.RcvSettleMode))
	l.str = l.eLink.String()
}