// Handle is called whenever containers change on the machine being watched.
// Machines start out with no containers so the first time Handle is called,
// it will be because a container has been added.
338143
func (cs *ContainerSetup) Handle(abort <-chan struct{}, containerIds []string) (resultError error) {
	// Consume the initial watcher event.
	if len(containerIds) == 0 {
		return nil
	}

	logger.Infof("initial container setup with ids: %v", containerIds)
	for _, id := range containerIds {
		containerType := state.ContainerTypeFromId(id)
		// If this container type has been dealt with, do nothing.
		if atomic.LoadInt32(cs.setupDone[containerType]) != 0 {
			continue
		}
		if err := cs.initialiseAndStartProvisioner(abort, containerType); err != nil {
			logger.Errorf("starting container provisioner for %v: %v", containerType, err)
			// Just because dealing with one type of container fails, we won't
			// exit the entire function because we still want to try and start
			// other container types. So we take note of and return the first
			// such error.
			if resultError == nil {
				resultError = err
			}
		}
	}
	return errors.Trace(resultError)
}
893113
func (s *Server) Handle(method string, handlerFunc interface{}) {
	addHandler(s.handlers, method, handlerFunc)
}
1256243
func (b *EventBus) handle(m eh.EventMatcher, h eh.EventHandler, ch <-chan evt) {
	b.wg.Add(1)
	defer b.wg.Done()

	for e := range ch {
		if !m(e.event) {
			continue
		}
		if err := h.HandleEvent(e.ctx, e.event); err != nil {
			select {
			case b.errCh <- eh.EventBusError{Err: fmt.Errorf("could not handle event (%s): %s", h.HandlerType(), err.Error()), Ctx: e.ctx, Event: e.event}:
			default:
			}
		}
	}
}
497066
func (bh *Handler) Handle(srv ab.AtomicBroadcast_BroadcastServer) error {
	addr := util.ExtractRemoteAddress(srv.Context())
	logger.Debugf("Starting new broadcast loop for %s", addr)
	for {
		msg, err := srv.Recv()
		if err == io.EOF {
			logger.Debugf("Received EOF from %s, hangup", addr)
			return nil
		}
		if err != nil {
			logger.Warningf("Error reading from %s: %s", addr, err)
			return err
		}

		resp := bh.ProcessMessage(msg, addr)
		err = srv.Send(resp)
		if resp.Status != cb.Status_SUCCESS {
			return err
		}

		if err != nil {
			logger.Warningf("Error sending to %s: %s", addr, err)
			return err
		}
	}

}
344079
func (self *StreamHandler) Handle(record *LogRecord) int {
	return self.BaseHandler.Handle2(self, record)
}
610142
func (w *TimeWait) handle() {
	var state int64
	atomic.StoreInt64(&state, 0)

	go func() {
		<-w.closer
		atomic.StoreInt64(&state, 1)
	}()

	for {
		time.Sleep(w.ms)

		bit := atomic.LoadInt64(&state)
		if bit > 0 {
			break
		}

		w.Done()
	}
}
521544
func Handle(ds storage.DeviceSession, rxPacket models.RXPacket, phy lorawan.PHYPayload) error {
	ctx := joinContext{
		DeviceSession: ds,
		PHYPayload:    phy,
		RXPacket:      rxPacket,
	}

	for _, t := range tasks {
		if err := t(&ctx); err != nil {
			return err
		}
	}

	return nil
}
131613
func (h *onRequestHandler) Handle(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	if OnRequest != nil {
		if err := OnRequest(ctx, w, req, store); err != nil {
			return err
		}
	}

	return h.handler(ctx, w, req, store)
}
48187
func (eh presencesReplaceEventHandler) Handle(s *Session, i interface{}) {
	if t, ok := i.(*PresencesReplace); ok {
		eh(s, t)
	}
}
1321349
func (f *Flag) Handle() (Handle, error) {
	transport, err := process.NewClient(f.Command)
	if err != nil {
		return nil, fmt.Errorf("failed to open plugin %q: %v", f.Name, err)
	}

	handle, err := NewTransportHandle(f.Name, transport)
	if err != nil {
		return nil, multierr.Combine(
			fmt.Errorf("failed to open plugin %q: %v", f.Name, err),
			transport.Close(),
		)
	}

	return handle, nil
}
52269
func (s *ServeMux) Handle(meth string, pat Pattern, h HandlerFunc) {
	s.handlers[meth] = append(s.handlers[meth], handler{pat: pat, h: h})
}
759358
func (m *Medeina) handle(method Method, handle Handle) {
	m.methods.Push(method)
	handle()
	m.methods.Pop()
}
632714
func (h *MultiHandler) Handle(w http.ResponseWriter, r *http.Request) error {
	req := new(info.Req)
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		log.Warningf("failed to read request body: %v", err)
		return errors.NewBadRequest(err)
	}
	r.Body.Close()

	err = json.Unmarshal(body, req)
	if err != nil {
		log.Warningf("failed to unmarshal request: %v", err)
		return errors.NewBadRequest(err)
	}

	log.Debug("checking label")
	if req.Label == "" {
		req.Label = h.defaultLabel
	}

	if _, ok := h.signers[req.Label]; !ok {
		log.Warningf("request for invalid endpoint")
		return errors.NewBadRequestString("bad label")
	}

	log.Debug("getting info")
	resp, err := h.signers[req.Label].Info(*req)
	if err != nil {
		log.Infof("error getting certificate: %v", err)
		return err
	}

	response := api.NewSuccessResponse(resp)
	w.Header().Set("Content-Type", "application/json")
	enc := json.NewEncoder(w)
	return enc.Encode(response)
}
918446
func (h *contextualHandler) Handle(err error) {
	err = With(err, h.keyvals...)

	h.handler.Handle(err)
}
926208
func (c *PairingController) Handle(cont util.Container) (util.Container, error) {
	method := PairMethodType(cont.GetByte(TagPairingMethod))
	perm := cont.GetByte(TagPermission)
	username := cont.GetString(TagUsername)
	publicKey := cont.GetBytes(TagPublicKey)

	log.Debug.Println("->     Method:", method)
	log.Debug.Println("-> Permission:", perm)
	log.Debug.Println("->   Username:", username)
	log.Debug.Println("->       LTPK:", publicKey)

	entity := db.NewEntity(username, publicKey, nil)

	out := util.NewTLV8Container()
	out.SetByte(TagSequence, 0x2)

	switch method {
	case PairingMethodDelete:
		log.Debug.Printf("Remove LTPK for client '%s'\n", username)
		c.database.DeleteEntity(entity)
	case PairingMethodAdd:
		err := c.database.SaveEntity(entity)
		if err != nil {
			log.Info.Panic(err)
			return nil, err
		}
	default:
		return nil, fmt.Errorf("Invalid pairing method type %v", method)
	}

	return out, nil
}
1259326
func (hdr *Handler) Handle(im *imageserver.Image, params imageserver.Params) (*imageserver.Image, error) {
	if !params.Has(param) {
		return im, nil
	}
	params, err := params.GetParams(param)
	if err != nil {
		return nil, err
	}
	if params.Empty() {
		return im, nil
	}
	im, err = hdr.handle(im, params)
	if err != nil {
		if err, ok := err.(*imageserver.ParamError); ok {
			err.Param = param + "." + err.Param
		}
		return nil, err
	}
	return im, nil
}
709184
func (mux *ServeMux) Handle(m Matcher, h Handler) {
	mux.handle(&muxEntry{m, h, false})
}