mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-09-27 03:45:52 +08:00
41 lines
809 B
Go
41 lines
809 B
Go
package streamd
|
|
|
|
import (
|
|
"github.com/xaionaro-go/streamctl/pkg/p2p/types"
|
|
)
|
|
|
|
type OptionsAggregated struct {
|
|
P2PSetupServer types.FuncSetupServer
|
|
P2PSetupClient types.FuncSetupClient
|
|
}
|
|
|
|
type Option interface {
|
|
apply(*OptionsAggregated)
|
|
}
|
|
|
|
type Options []Option
|
|
|
|
func (s Options) apply(opts *OptionsAggregated) {
|
|
for _, opt := range s {
|
|
opt.apply(opts)
|
|
}
|
|
}
|
|
|
|
func (s Options) Aggregate() OptionsAggregated {
|
|
opts := OptionsAggregated{}
|
|
s.apply(&opts)
|
|
return opts
|
|
}
|
|
|
|
type OptionP2PSetupServer types.FuncSetupServer
|
|
|
|
func (opt OptionP2PSetupServer) apply(opts *OptionsAggregated) {
|
|
opts.P2PSetupServer = types.FuncSetupServer(opt)
|
|
}
|
|
|
|
type OptionP2PSetupClient types.FuncSetupClient
|
|
|
|
func (opt OptionP2PSetupClient) apply(opts *OptionsAggregated) {
|
|
opts.P2PSetupClient = types.FuncSetupClient(opt)
|
|
}
|