// FromChan returns a streaming request that fetches calls from the given channel until it closes.
// If a nil chan is specified then the returned func will always generate nil.
197988
func FromChan(ch <-chan *executor.Call) RequestStreamingFunc {
	if ch == nil {
		// avoid blocking forever if we're handed a nil chan
		return func() *executor.Call { return nil }
	}
	return func() *executor.Call {
		if m, ok := <-ch; ok {
			return m
		}
		return nil
	}
}
1117229
func FetchBackupForChan(chanPoint wire.OutPoint,
	chanSource LiveChannelSource) (*Single, error) {

	// First, we'll query the channel source to see if the channel is known
	// and open within the database.
	targetChan, err := chanSource.FetchChannel(chanPoint)
	if err != nil {
		// If we can't find the channel, then we return with an error,
		// as we have nothing to  backup.
		return nil, fmt.Errorf("unable to find target channel")
	}

	// Once we have the target channel, we can assemble the backup using
	// the source to obtain any extra information that we may need.
	staticChanBackup, err := assembleChanBackup(chanSource, targetChan)
	if err != nil {
		return nil, fmt.Errorf("unable to create chan backup: %v", err)
	}

	return staticChanBackup, nil
}
282744
func (ls *LState) ToChannel(n int) chan LValue {
	if lv, ok := ls.Get(n).(LChannel); ok {
		return (chan LValue)(lv)
	}
	return nil
}
534579
func (cm *CodecMap) FromNetAddr(a net.Addr) (ma.Multiaddr, error) {
	if a == nil {
		return nil, fmt.Errorf("nil multiaddr")
	}
	p, err := cm.getAddrParser(a.Network())
	if err != nil {
		return nil, err
	}

	return p(a)
}
1239073
func FromCli(c *cli.Context) (plugin.Middleware, error) {
	return FromOther(
		RateLimit{
			PeriodSeconds: int64(c.Int("period")),
			Requests:      int64(c.Int("requests")),
			Burst:         int64(c.Int("burst")),
			Variable:      c.String("var"),
			RateVar:       c.String("rateVar")})
}
336068
func (s *SearchSource) From(from int) *SearchSource {
	s.from = from
	return s
}
903777
func FromRequest(r *http.Request) *zerolog.Logger {
	return log.Ctx(r.Context())
}
856658
func (req *Request) OfChannel(ch string) *Request {
	req.lastChannel = ch
	return req
}
375214
func FromChain(endSink Sink, sinks ...MiddlewareConstructor) Sink {
	for i := len(sinks) - 1; i >= 0; i-- {
		endSink = sinks[i](endSink)
	}
	return endSink
}
1116877
func (c *Client) disconnectChan() <-chan struct{} {
	c.mtx.Lock()
	ch := c.disconnect
	c.mtx.Unlock()
	return ch
}
820807
func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error) {
	ch := make(chan Update, bot.Buffer)

	go func() {
		for {
			select {
			case <-bot.shutdownChannel:
				return
			default:
			}
			
			updates, err := bot.GetUpdates(config)
			if err != nil {
				log.Println(err)
				log.Println("Failed to get updates, retrying in 3 seconds...")
				time.Sleep(time.Second * 3)

				continue
			}

			for _, update := range updates {
				if update.UpdateID >= config.Offset {
					config.Offset = update.UpdateID + 1
					ch <- update
				}
			}
		}
	}()

	return ch, nil
}
1309377
func FromChannel(source <-chan interface{}) Query {
	return Query{
		Iterate: func() Iterator {
			return func() (item interface{}, ok bool) {
				item, ok = <-source
				return
			}
		},
	}
}
776838
func (c *UsergroupsCreateCall) FromValues(v url.Values) error {
	var tmp UsergroupsCreateCall
	if raw := strings.TrimSpace(v.Get("channels")); len(raw) > 0 {
		tmp.channels = raw
	}
	if raw := strings.TrimSpace(v.Get("description")); len(raw) > 0 {
		tmp.description = raw
	}
	if raw := strings.TrimSpace(v.Get("handle")); len(raw) > 0 {
		tmp.handle = raw
	}
	if raw := strings.TrimSpace(v.Get("include_count")); len(raw) > 0 {
		parsed, err := strconv.ParseBool(raw)
		if err != nil {
			return errors.Wrap(err, `failed to parse boolean value "include_count"`)
		}
		tmp.includeCount = parsed
	}
	if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
		tmp.name = raw
	}
	*c = tmp
	return nil
}
1180821
func (s *packetManager) workerChan(runWorker func(chan orderedRequest),
) chan orderedRequest {

	// multiple workers for faster read/writes
	rwChan := make(chan orderedRequest, SftpServerWorkerCount)
	for i := 0; i < SftpServerWorkerCount; i++ {
		runWorker(rwChan)
	}

	// single worker to enforce sequential processing of everything else
	cmdChan := make(chan orderedRequest)
	runWorker(cmdChan)

	pktChan := make(chan orderedRequest, SftpServerWorkerCount)
	go func() {
		for pkt := range pktChan {
			switch pkt.requestPacket.(type) {
			case *sshFxpReadPacket, *sshFxpWritePacket:
				s.incomingPacket(pkt)
				rwChan <- pkt
				continue
			case *sshFxpClosePacket:
				// wait for reads/writes to finish when file is closed
				// incomingPacket() call must occur after this
				s.working.Wait()
			}
			s.incomingPacket(pkt)
			// all non-RW use sequential cmdChan
			cmdChan <- pkt
		}
		close(rwChan)
		close(cmdChan)
		s.close()
	}()

	return pktChan
}
985664
func FromJSON(data *[]byte, current string, namespace *[]string) error {

	var m map[string]interface{}
	err := json.Unmarshal(*data, &m)

	if err != nil {
		return err
	}

	return FromMap(m, current, namespace)
}
193057
func (cmd AppCmd) waitChan() <-chan string {
	ch := make(chan string, 1)
	go func() {
		_ = cmd.Wait()
		state := cmd.ProcessState
		exitStatus := " unknown "
		if state != nil {
			exitStatus = state.String()
		}

		ch <- exitStatus
	}()
	return ch
}
575300
func (c *Chan) SendChan() chan<- interface{} {

	c.mutx.Lock()
	defer c.mutx.Unlock()

	if c.sendch == nil {
		c.sendch = make(chan interface{})
		go c.sendLoop()
	}
	return c.sendch
}