// NewProtocols creates an object of type Protocols if possible, returning an error if not.
169286
func NewProtocols(in interface{}, context *compiler.Context) (*Protocols, error) {
	errors := make([]error, 0)
	x := &Protocols{}
	m, ok := compiler.UnpackMap(in)
	if !ok {
		message := fmt.Sprintf("has unexpected value: %+v (%T)", in, in)
		errors = append(errors, compiler.NewError(context, message))
	} else {
		allowedKeys := []string{"resumable", "simple"}
		var allowedPatterns []*regexp.Regexp
		invalidKeys := compiler.InvalidKeysInMap(m, allowedKeys, allowedPatterns)
		if len(invalidKeys) > 0 {
			message := fmt.Sprintf("has invalid %s: %+v", compiler.PluralProperties(len(invalidKeys)), strings.Join(invalidKeys, ", "))
			errors = append(errors, compiler.NewError(context, message))
		}
		// Simple simple = 1;
		v1 := compiler.MapValueForKey(m, "simple")
		if v1 != nil {
			var err error
			x.Simple, err = NewSimple(v1, compiler.NewContext("simple", context))
			if err != nil {
				errors = append(errors, err)
			}
		}
		// Resumable resumable = 2;
		v2 := compiler.MapValueForKey(m, "resumable")
		if v2 != nil {
			var err error
			x.Resumable, err = NewResumable(v2, compiler.NewContext("resumable", context))
			if err != nil {
				errors = append(errors, err)
			}
		}
	}
	return x, compiler.NewErrorGroupOrNil(errors)
}
146312
func NewDefaultChannelProtocols(channels []ChannelType) map[string]ChannelProtocolConfig {
	return map[string]ChannelProtocolConfig{
		"":                             {Binary: true, Channels: channels},
		ChannelWebSocketProtocol:       {Binary: true, Channels: channels},
		Base64ChannelWebSocketProtocol: {Binary: false, Channels: channels},
	}
}
18313
func (rc *ReadinessCheck) SetProtocol(proto string) *ReadinessCheck {
	rc.Protocol = proto
	return rc
}
102660
func NewDefaultReaderProtocols() map[string]ReaderProtocolConfig {
	return map[string]ReaderProtocolConfig{
		"":                            {Binary: true},
		binaryWebSocketProtocol:       {Binary: true},
		base64BinaryWebSocketProtocol: {Binary: false},
	}
}
267132
func (s *InstancePortInfo) SetProtocol(v string) *InstancePortInfo {
	s.Protocol = &v
	return s
}
723931
func setupProtocol(msg *transport.Message, node *registry.Node) codec.NewCodec {
	protocol := node.Metadata["protocol"]

	// got protocol
	if len(protocol) > 0 {
		return nil
	}

	// no protocol use old codecs
	switch msg.Header["Content-Type"] {
	case "application/json":
		msg.Header["Content-Type"] = "application/json-rpc"
	case "application/protobuf":
		msg.Header["Content-Type"] = "application/proto-rpc"
	}

	// now return codec
	return defaultCodecs[msg.Header["Content-Type"]]
}
148245
func (s *PortInfo) SetProtocol(v string) *PortInfo {
	s.Protocol = &v
	return s
}
280477
func (k *KBFSService) registerProtocols(
	srv *rpc.Server, xp rpc.Transporter) error {
	// TODO: fill in with actual protocols.
	protocols := []rpc.Protocol{
		kbgitkbfs.DiskBlockCacheProtocol(NewDiskBlockCacheService(k.config)),
	}
	for _, proto := range protocols {
		if err := srv.Register(proto); err != nil {
			return err
		}
	}
	return nil
}
645485
func (c *Websocket) Subprotocol() *String {
	s := &String{chain: c.chain}
	if c.conn != nil {
		s.value = c.conn.Subprotocol()
	}
	return s
}
442547
func (s *Subscription) SetProtocol(v string) *Subscription {
	s.Protocol = &v
	return s
}
258280
func (s *UpdateListenerInput) SetProtocol(v string) *UpdateListenerInput {
	s.Protocol = &v
	return s
}
123358
func (e *PodEndpoint) AddProtocol(protocol string) *PodEndpoint {
	e.Protocol = append(e.Protocol, protocol)
	return e
}
1078423
func RegisterProtocol(protocol string, f ALTSRecordFunc) error {
	if _, ok := protocols[protocol]; ok {
		return fmt.Errorf("protocol %v is already registered", protocol)
	}
	protocols[protocol] = f
	return nil
}
328700
func (s *Redirect) SetProtocol(v string) *Redirect {
	s.Protocol = &v
	return s
}
886506
func NewProtocolManager(
	chainConfig *params.ChainConfig,
	indexerConfig *light.IndexerConfig,
	lightSync bool,
	networkId uint64,
	mux *event.TypeMux,
	engine consensus.Engine,
	peers *peerSet,
	blockchain BlockChain,
	txpool txPool,
	chainDb ethdb.Database,
	odr *LesOdr,
	txrelay *LesTxRelay,
	serverPool *serverPool,
	quitSync chan struct{},
	wg *sync.WaitGroup,
	ulcConfig *eth.ULCConfig) (*ProtocolManager, error) {
	// Create the protocol manager with the base fields
	manager := &ProtocolManager{
		lightSync:   lightSync,
		eventMux:    mux,
		blockchain:  blockchain,
		chainConfig: chainConfig,
		iConfig:     indexerConfig,
		chainDb:     chainDb,
		odr:         odr,
		networkId:   networkId,
		txpool:      txpool,
		txrelay:     txrelay,
		serverPool:  serverPool,
		peers:       peers,
		newPeerCh:   make(chan *peer),
		quitSync:    quitSync,
		wg:          wg,
		noMorePeers: make(chan struct{}),
	}
	if odr != nil {
		manager.retriever = odr.retriever
		manager.reqDist = odr.retriever.dist
	} else {
		manager.servingQueue = newServingQueue(int64(time.Millisecond * 10))
	}

	if ulcConfig != nil {
		manager.ulc = newULC(ulcConfig)
	}

	removePeer := manager.removePeer
	if disableClientRemovePeer {
		removePeer = func(id string) {}
	}
	if lightSync {
		var checkpoint uint64
		if cht, ok := params.TrustedCheckpoints[blockchain.Genesis().Hash()]; ok {
			checkpoint = (cht.SectionIndex+1)*params.CHTFrequency - 1
		}
		manager.downloader = downloader.New(downloader.LightSync, checkpoint, chainDb, manager.eventMux, nil, blockchain, removePeer)
		manager.peers.notify((*downloaderPeerNotify)(manager))
		manager.fetcher = newLightFetcher(manager)
	}
	return manager, nil
}
588513
func (s *CreateTargetGroupInput) SetProtocol(v string) *CreateTargetGroupInput {
	s.Protocol = &v
	return s
}
407630
func New(w Protocol) *DnstapIO {
	dio := DnstapIO{}
	dio.protocol = w
	dio.queue = make(chan tap.Dnstap, 10)
	dio.stop = make(chan bool)
	go dio.serve()
	return &dio
}