mirror of
https://github.com/openziti/ziti.git
synced 2026-09-10 16:55:41 +00:00
08aa26a051
- channel.NewChannel(name, factory, bindHandler, opts) -> channel.NewSingleChannel(...) - channel.NewChannelWithUnderlay(...) -> channel.NewSingleChannelWithUnderlay(...) channel/v5 repurposes NewChannel for the unified multi-underlay constructor, so the single-underlay call sites move to the renamed helpers. Mechanical rename only; like the preceding import commit it does not build on its own.
27 lines
904 B
Go
27 lines
904 B
Go
package testutil
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/openziti/channel/v5"
|
|
"github.com/openziti/ziti/v2/common/handler_common"
|
|
"github.com/openziti/ziti/v2/common/pb/ctrl_pb"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func AcceptControl(id string, uf channel.UnderlayFactory, assertions *require.Assertions) (channel.Channel, *MessageCollector) {
|
|
msgc := NewMessageCollector(id)
|
|
bindHandler := func(binding channel.Binding) error {
|
|
binding.AddReceiveHandler(channel.AnyContentType, msgc)
|
|
binding.AddReceiveHandlerF(int32(ctrl_pb.ContentType_VerifyRouterType), func(msg *channel.Message, ch channel.Channel) {
|
|
handler_common.SendSuccess(msg, ch, "link success")
|
|
})
|
|
return nil
|
|
}
|
|
|
|
timeoutUF := NewTimeoutUnderlayFactory(uf, 2*time.Second)
|
|
ch, err := channel.NewSingleChannel(id, timeoutUF, channel.BindHandlerF(bindHandler), channel.DefaultOptions())
|
|
assertions.NoError(err)
|
|
return ch, msgc
|
|
}
|