2021-02-10 20:26:45 +00:00
|
|
|
//go:generate mockgen -source=$GOFILE -destination=./../../internal/mock/endpoint/protocol_handler.mock.go -package=endpoint_mock
|
|
|
|
|
|
|
|
package endpoint
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-07-24 12:45:47 +02:00
|
|
|
"github.com/mitchellh/mapstructure"
|
2021-02-10 20:26:45 +00:00
|
|
|
"github.com/soheilhy/cmux"
|
|
|
|
)
|
|
|
|
|
2021-07-24 12:45:47 +02:00
|
|
|
var (
|
|
|
|
WithDecodeHook = func(decodeHook mapstructure.DecodeHookFunc) UnmarshalOption {
|
|
|
|
return func(cfg *mapstructure.DecoderConfig) {
|
|
|
|
cfg.DecodeHook = decodeHook
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WithErrorUnused = UnmarshalOption(func(cfg *mapstructure.DecoderConfig) {
|
|
|
|
cfg.ErrorUnused = true
|
|
|
|
})
|
|
|
|
WithZeroFields = UnmarshalOption(func(cfg *mapstructure.DecoderConfig) {
|
|
|
|
cfg.ZeroFields = true
|
|
|
|
})
|
|
|
|
WithWeaklyTypedInput = UnmarshalOption(func(cfg *mapstructure.DecoderConfig) {
|
|
|
|
cfg.WeaklyTypedInput = true
|
|
|
|
})
|
|
|
|
WithSquash = UnmarshalOption(func(cfg *mapstructure.DecoderConfig) {
|
|
|
|
cfg.Squash = true
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
type UnmarshalOption func(cfg *mapstructure.DecoderConfig)
|
|
|
|
|
2021-02-10 20:26:45 +00:00
|
|
|
type Lifecycle interface {
|
|
|
|
Name() string
|
|
|
|
Uplink() Uplink
|
2021-07-24 12:45:47 +02:00
|
|
|
UnmarshalOptions(cfg interface{}, opts ...UnmarshalOption) error
|
2021-02-10 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProtocolHandler interface {
|
2021-04-26 22:35:28 +02:00
|
|
|
Start(ctx context.Context, lifecycle Lifecycle) error
|
2021-02-10 20:26:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type MultiplexHandler interface {
|
|
|
|
ProtocolHandler
|
|
|
|
Matchers() []cmux.Matcher
|
|
|
|
}
|