// Action sets the handler that will be called after all the middleware has been invoked. This is set to martini.Router in a martini.Classic().
480428
func (m *Martini) Action(handler Handler) {
	validateHandler(handler)
	m.action = handler
}
1270401
func (t *FixedInterval) action() {
	t.Lock()
	defer t.Unlock()

	if !t.running() || t.timer.Stop() {
		// Something went wrong here, not sure how
		return
	}

	// Set the timer to nil to indicate we've stopped
	t.timer = nil

	// Dispatch the internal event
	if err := t.Dispatcher.Dispatch(t.etype, nil); err != nil {
		t.echan <- err
		return
	}

	// Create a new timer for the next action
	t.timer = time.AfterFunc(t.GetDelay(), t.action)
}
1294466
func HandleAction(action interface{}, context *Context) (err error) {
	switch a := action.(type) {
	case ActionFunc:
		return a(context)
	case func(*Context) error:
		return a(context)
	case func(*Context): // deprecated function signature
		a(context)
		return nil
	}

	return errInvalidActionType
}
804426
func (s *AliasService) Action(action ...AliasAction) *AliasService {
	s.actions = append(s.actions, action...)
	return s
}
118989
func (mod *JabberBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		chat := xmpp.Chat{Type: "chat"}

		action.Options.Bind("user", &chat.Remote)
		action.Options.Bind("text", &chat.Text)

		mod.client.Send(chat)

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
437692
func (mod *HTTPBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	u := ""
	action.Options.Bind("url", &u)

	switch action.Name {
	case "get":
		resp, err := http.Get(u)
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}
		defer resp.Body.Close()

		b, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}

		ev, err := mod.prepareResponseEvent(b)
		if err == nil {
			ev.Name = "get"
			ev.Options.SetValue("url", "url", u)
			mod.eventChan <- ev
		}

	case "post":
		var err error
		var b []byte
		var j string
		var form url.Values
		var resp *http.Response

		action.Options.Bind("json", &j)
		action.Options.Bind("form", &form)

		if j != "" {
			buf := strings.NewReader(j)
			resp, err = http.Post(u, "application/json", buf)
		} else {
			resp, err = http.PostForm(u, form)
		}
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}
		defer resp.Body.Close()

		b, err = ioutil.ReadAll(resp.Body)
		if err != nil {
			mod.LogErrorf("Error: %s", err)
			return outs
		}

		ev, err := mod.prepareResponseEvent(b)
		if err == nil {
			ev.Name = "post"
			ev.Options.SetValue("url", "url", u)
			mod.eventChan <- ev
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
90506
func (f *workflowFixer) Action(ctx context.Context, path, name string) error {
	if len(f.node.Actions) == 0 {
		// Action was already run.
		return nil
	}
	err := f.fixer.Action(ctx, name)
	if err != nil {
		f.node.Log = fmt.Sprintf("action %v failed: %v", name, err)
	} else {
		f.node.Log = fmt.Sprintf("action %v successful", name)
	}
	f.node.Actions = f.node.Actions[:0]
	f.node.State = workflowpb.WorkflowState_Done
	f.node.Message = "Addressed(" + name + "): " + f.node.Message
	f.node.Display = workflow.NodeDisplayNone
	f.node.BroadcastChanges(false /* updateChildren */)
	f.wg.Done()
	return nil
}
1023081
func (f *FlagClause) Action(action Action) *FlagClause {
	f.addAction(action)
	return f
}
293578
func (a *Application) Action(action Action) *Application {
	a.addAction(action)
	return a
}
477388
func Execute(a *Action) error {
	seen := make(map[*Action]error)
	return execute(seen, a)
}
791239
func (t *transaction) doAction(a *action) (interface{}, error) {
	switch a.kind {
	case actionCommand:
		return t.conn.Do(a.name, a.args...)
	case actionScript:
		return a.script.Do(t.conn, a.args...)
	}
	return nil, nil
}
968260
func (mod *SimplepushBee) Action(action bees.Action) []bees.Placeholder {
	outs := []bees.Placeholder{}

	switch action.Name {
	case "send":
		sm := simplepush.Message{
			SimplePushKey: mod.key,
			Encrypt:       mod.password != "",
			Password:      mod.password,
			Salt:          mod.salt,
		}
		action.Options.Bind("title", &sm.Title)
		action.Options.Bind("message", &sm.Message)
		action.Options.Bind("event", &sm.Event)

		simplepush.Send(sm)

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
261234
func (mod *GitHubBee) Action(action bees.Action) []bees.Placeholder {
	ctx := context.Background()
	outs := []bees.Placeholder{}
	switch action.Name {
	case "follow":
		var user string
		action.Options.Bind("username", &user)

		if _, err := mod.client.Users.Follow(ctx, user); err != nil {
			mod.LogErrorf("Failed to follow user: %v", err)
		}

	case "unfollow":
		var user string
		action.Options.Bind("username", &user)

		if _, err := mod.client.Users.Unfollow(ctx, user); err != nil {
			mod.LogErrorf("Failed to follow user: %v", err)
		}

	case "star":
		var user string
		var repo string
		action.Options.Bind("owner", &user)
		action.Options.Bind("repository", &repo)

		if _, err := mod.client.Activity.Star(ctx, user, repo); err != nil {
			mod.LogErrorf("Failed to star repository: %v", err)
		}

	case "unstar":
		var user string
		var repo string
		action.Options.Bind("owner", &user)
		action.Options.Bind("repository", &repo)

		if _, err := mod.client.Activity.Unstar(ctx, user, repo); err != nil {
			mod.LogErrorf("Failed to unstar repository: %v", err)
		}

	default:
		panic("Unknown action triggered in " + mod.Name() + ": " + action.Name)
	}

	return outs
}
1168958
func (mod *HelloBee) Action(action bees.Action) []bees.Placeholder {
	return []bees.Placeholder{}
}
1025440
func (r *ActionResponse) AddAction(action *bees.Action) {
	r.actions = append(r.actions, action)
	r.Actions = append(r.Actions, prepareActionResponse(r.Context, action))
}
761285
func (f *Facade) Actions(args params.Entities) params.ActionResults {
	actionFn := common.AuthAndActionFromTagFn(f.accessMachine, f.backend.ActionByTag)
	return common.Actions(args, actionFn)
}
1346004
func (m *NodeManager) Action(ctx context.Context, ap *ActionParameters) error {
	n, err := m.getNodeByPath(ap.Path)
	if err != nil {
		return err
	}

	m.mu.Lock()

	if n.Listener == nil {
		m.mu.Unlock()
		return fmt.Errorf("Action %v is invoked on a node without listener (node path is %v)", ap.Name, ap.Path)
	}
	nodeListener := n.Listener
	m.mu.Unlock()

	return nodeListener.Action(ctx, ap.Path, ap.Name)
}