// Manager provides a mock function with given fields: channelID
199334
func (_m *ChannelPolicyManagerGetter) Manager(channelID string) (policies.Manager, bool) {
	ret := _m.Called(channelID)

	var r0 policies.Manager
	if rf, ok := ret.Get(0).(func(string) policies.Manager); ok {
		r0 = rf(channelID)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(policies.Manager)
		}
	}

	var r1 bool
	if rf, ok := ret.Get(1).(func(string) bool); ok {
		r1 = rf(channelID)
	} else {
		r1 = ret.Get(1).(bool)
	}

	return r0, r1
}
103607
func (c *Client) SetChannelCommander(val bool) error {
	return c.ClientUpdate(NewArg(ClientIsChannelCommander, val))
}
509993
func (c *Client) RegisterChannel(id uint) error {
	_, err := c.ExecCmd(NewCmd("servernotifyregister").WithArgs(
		NewArg("event", ChannelEvents),
		NewArg("id", id),
	))
	return err
}
670041
func (rtm *Client) InviteUser(channelID, userID string) (*Channel, error) {
	res := channelsInfoResponse{}
	err := NewExternalRequest().
		AsPost().
		WithScheme(APIScheme).
		WithHost(APIEndpoint).
		WithPath("api/channels.invite").
		WithPostData("token", rtm.Token).
		WithPostData("channel", channelID).
		WithPostData("user", userID).
		JSON(&res)

	if err != nil {
		return nil, err
	}

	if !IsEmpty(res.Error) {
		return nil, exception.New(res.Error)
	}

	return res.Channel, nil
}
1337229
func (g *Gui) SetManager(managers ...Manager) {
	g.managers = managers
	g.currentView = nil
	g.views = nil
	g.keybindings = nil

	go func() { g.tbEvents <- termbox.Event{Type: termbox.EventResize} }()
}
646324
func (e *Engine) manager() {
	for {
		select {
		case n := <-e.notifier.C:
			log.Infof("Received cluster config notification; %v", &n)

			e.syncServer.notify(&SyncNote{Type: SNTConfigUpdate})

			e.clusterLock.Lock()
			e.cluster = n.Cluster
			e.clusterLock.Unlock()

			if n.MetadataOnly {
				log.Infof("Only metadata changes found, processing complete.")
				continue
			}

			if ha, err := e.haConfig(); err != nil {
				log.Errorf("Manager failed to determine haConfig: %v", err)
			} else if ha.Enabled {
				e.haManager.enable()
			} else {
				e.haManager.disable()
			}

			node, err := e.thisNode()
			if err != nil {
				log.Errorf("Manager failed to identify local node: %v", err)
				continue
			}
			if !node.VserversEnabled {
				e.shutdownVservers()
				e.deleteVLANs()
				continue
			}

			// Process new cluster configuration.
			e.updateVLANs()

			// TODO(jsing): Ensure this does not block.
			e.updateVservers()

		case state := <-e.haManager.stateChan:
			log.Infof("Received HA state notification %v", state)
			e.haManager.setState(state)

		case status := <-e.haManager.statusChan:
			log.Infof("Received HA status notification (%v)", status.State)
			e.haManager.setStatus(status)

		case <-e.haManager.timer():
			log.Infof("Timed out waiting for HAState")
			e.haManager.setState(seesaw.HAUnknown)

		case svs := <-e.vserverChan:
			if _, ok := e.vservers[svs.Name]; !ok {
				log.Infof("Received vserver snapshot for unconfigured vserver %s, ignoring", svs.Name)
				break
			}
			log.V(1).Infof("Updating vserver snapshot for %s", svs.Name)
			e.vserverLock.Lock()
			e.vserverSnapshots[svs.Name] = svs
			e.vserverLock.Unlock()

		case override := <-e.overrideChan:
			sn := &SyncNote{Type: SNTOverride}
			switch o := override.(type) {
			case *seesaw.BackendOverride:
				sn.BackendOverride = o
			case *seesaw.DestinationOverride:
				sn.DestinationOverride = o
			case *seesaw.VserverOverride:
				sn.VserverOverride = o
			}
			e.syncServer.notify(sn)
			e.handleOverride(override)

		case <-e.shutdown:
			log.Info("Shutting down engine...")

			// Tell other components to shutdown and then wait for
			// them to do so.
			e.shutdownIPC <- true
			e.shutdownRPC <- true
			<-e.shutdownIPC
			<-e.shutdownRPC

			e.syncClient.disable()
			e.shutdownVservers()
			e.hcManager.shutdown()
			e.deleteVLANs()

			log.Info("Shutdown complete")
			return
		}
	}
}
372113
func Handle(h Handler) {
	m := &manager{
		Reader:  os.Stdin,
		Writer:  os.Stdout,
		Handler: h,
	}

	m.Start()
}
13976
func (r *ChannelRouter) GetChannelByID(chanID lnwire.ShortChannelID) (
	*channeldb.ChannelEdgeInfo,
	*channeldb.ChannelEdgePolicy,
	*channeldb.ChannelEdgePolicy, error) {

	return r.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
}
1303553
func FakeManager(failingControllers int) *Manager {
	m := &Manager{
		controllers: controllerMap{},
	}

	for i := 0; i < failingControllers; i++ {
		ctrl := &Controller{
			name:              fmt.Sprintf("controller-%d", i),
			uuid:              fmt.Sprintf("%d", i),
			stop:              make(chan struct{}, 0),
			update:            make(chan struct{}, 1),
			terminated:        make(chan struct{}, 0),
			lastError:         fmt.Errorf("controller failed"),
			failureCount:      1,
			consecutiveErrors: 1,
		}

		ctrl.ctxDoFunc, ctrl.cancelDoFunc = context.WithCancel(context.Background())
		m.controllers[ctrl.name] = ctrl
	}

	return m
}
236176
func (q *Queue) manage() {
	defer q.wg.Done()

	for {

		if q.bu.Length() == 0 {
			select {
			case item, open := <-q.enq:
				if !open {
					// possibly closed,return
					return
				}
				q.bu.Enqueue(item)
				q.done <- true
			}
		}

		if q.bu.Length() > 0 {

			// cache the first item to preseve it else if we dequeue it will be lost when an enqueue is received
			firstItem, err := q.bu.Peek()

			if err != nil {
				// we know there is was an item in the queue,hence we retake the operation to ensure we didnt miss
				continue
			}

			// we order up the queueu-dequeue operations and ensure the first item was delivered to the out-channel provided
			select {
			// wait for an item to be delivered into the queue or till the queue is closed
			case item, open := <-q.enq:
				if !open {
					// possibly closed,return
					return
				}
				q.bu.Enqueue(item)
				q.done <- true

			// send out the first item as guaranteed
			case q.Deq <- firstItem:
				q.bu.Dequeue()
			}
		}

	}
}
390013
func NewChannelEventListener(em event.EventMachine) *ChannelEventListener {
	return &ChannelEventListener{em: em, ids: []uint64{}}
}
805357
func (m *Manager) Manager(path []string) (policies.Manager, bool) {
	if len(path) == 0 {
		return m, true
	}
	manager, ok := m.SubManagersMap[path[len(path)-1]]
	return manager, ok
}
180443
func (g *Gui) SetManagerFunc(manager func(*Gui) error) {
	g.SetManager(ManagerFunc(manager))
}
37149
func (ph *Manager) Handle(pl Plugin) {
	if _, ok := ph.plugins[pl.Name()]; ok {
		//Already exists
		panic(DuplicatePlugin)
	}

	ph.plugins[pl.Name()] = pl

	for _, sub := range pl.Subscribes() {
		if ph.subscriptions[sub] == nil {
			ph.subscriptions[sub] = make(plugins)
		}
		ph.subscriptions[sub][pl.Name()] = pl
	}

	f, ch, closer := generatefunc(pl)
	ph.closers[pl.Name()] = closer

	go f()

	rch := reflect.ValueOf(ch)
	ph.selects = append(ph.selects,
		reflect.SelectCase{
			Dir:  reflect.SelectRecv,
			Chan: rch,
		})
}
550772
func (c *ConfigLocal) KeyManager() KeyManager {
	c.lock.RLock()
	defer c.lock.RUnlock()
	return c.keyman
}
230562
func (service *Service) Manage() (string, error) {

	usage := "Usage: myservice install | remove | start | stop | status"

	// if received any kind of command, do it
	if len(os.Args) > 1 {
		command := os.Args[1]
		switch command {
		case "install":
			return service.Install()
		case "remove":
			return service.Remove()
		case "start":
			return service.Start()
		case "stop":
			return service.Stop()
		case "status":
			return service.Status()
		default:
			return usage, nil
		}
	}

	// Do something, call your goroutines, etc

	// Set up channel on which to send signal notifications.
	// We must use a buffered channel or risk missing the signal
	// if we're not ready to receive when the signal is sent.
	interrupt := make(chan os.Signal, 1)
	signal.Notify(interrupt, os.Interrupt, os.Kill, syscall.SIGTERM)

	// Set up listener for defined host and port
	listener, err := net.Listen("tcp", port)
	if err != nil {
		return "Possibly was a problem with the port binding", err
	}

	// set up channel on which to send accepted connections
	listen := make(chan net.Conn, 100)
	go acceptConnection(listener, listen)

	// loop work cycle with accept connections or interrupt
	// by system signal
	for {
		select {
		case conn := <-listen:
			go handleClient(conn)
		case killSignal := <-interrupt:
			stdlog.Println("Got signal:", killSignal)
			stdlog.Println("Stoping listening on ", listener.Addr())
			listener.Close()
			if killSignal == os.Interrupt {
				return "Daemon was interrupted by system signal", nil
			}
			return "Daemon was killed", nil
		}
	}
}
673142
func NewDeadManager(err error) *Manager {
	var secretary dummySecretary
	m := Manager{
		config: ManagerConfig{
			Secretary: func(_ string) (Secretary, error) {
				return secretary, nil
			},
		},
	}
	_ = catacomb.Invoke(catacomb.Plan{
		Site: &m.catacomb,
		Work: func() error {
			return errors.Trace(err)
		},
	})
	return &m
}