<commit_before>package stellargregor

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"strings"

	"github.com/keybase/client/go/gregor"
	"github.com/keybase/client/go/libkb"
	"github.com/keybase/client/go/protocol/gregor1"
	"github.com/keybase/client/go/protocol/stellar1"
	"github.com/keybase/client/go/stellar"
)

type Handler struct {
	libkb.Contextified
	walletState *stellar.WalletState
}

var _ libkb.GregorInBandMessageHandler = (*Handler)(nil)

func New(g *libkb.GlobalContext, walletState *stellar.WalletState) *Handler {
	return &Handler{
		Contextified: libkb.NewContextified(g),
		walletState:  walletState,
	}
}

func (h *Handler) Create(ctx context.Context, cli gregor1.IncomingInterface, category string, item gregor.Item) (bool, error) {
	mctx := libkb.NewMetaContext(ctx, h.G()).WithLogTag("WGR")
	switch category {
	case stellar1.PushAutoClaim:
		return true, h.autoClaim(mctx, cli, category, item)
	case stellar1.PushPaymentStatus:
		return true, h.paymentStatus(mctx, cli, category, item)
	case stellar1.PushPaymentNotification:
		return true, h.paymentNotification(mctx, cli, category, item)
	case stellar1.PushRequestStatus:
		return true, h.requestStatus(mctx, cli, category, item)
	case stellar1.PushAccountChange:
		return true, h.accountChange(mctx, cli, category, item)
	default:
		if strings.HasPrefix(category, "stellar.") {
			return false, fmt.Errorf("unknown handler category: %q", category)
		}
		return false, nil
	}
}

func (h *Handler) Dismiss(ctx context.Context, cli gregor1.IncomingInterface, category string, item gregor.Item) (bool, error) {
	return false, nil
}

func (h *Handler) IsAlive() bool {
	return true
}<commit_msg>Use goroutines for all IBM handlers (#16285)<commit_after>package stellargregor

import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"strings"

	"github.com/keybase/client/go/gregor"
	"github.com/keybase/client/go/libkb"
	"github.com/keybase/client/go/protocol/gregor1"
	"github.com/keybase/client/go/protocol/stellar1"
	"github.com/keybase/client/go/stellar"
)

type Handler struct {
	libkb.Contextified
	walletState *stellar.WalletState
}

var _ libkb.GregorInBandMessageHandler = (*Handler)(nil)

func New(g *libkb.GlobalContext, walletState *stellar.WalletState) *Handler {
	return &Handler{
		Contextified: libkb.NewContextified(g),
		walletState:  walletState,
	}
}

func (h *Handler) Create(ctx context.Context, cli gregor1.IncomingInterface, category string, item gregor.Item) (bool, error) {
	mctx := libkb.NewMetaContextBackground(h.G()).WithLogTag("WAIBM")
	switch category {
	case stellar1.PushAutoClaim:
		go h.autoClaim(mctx, cli, category, item)
		return true, nil
	case stellar1.PushPaymentStatus:
		go h.paymentStatus(mctx, cli, category, item)
		return true, nil
	case stellar1.PushPaymentNotification:
		go h.paymentNotification(mctx, cli, category, item)
		return true, nil
	case stellar1.PushRequestStatus:
		go h.requestStatus(mctx, cli, category, item)
		return true, nil
	case stellar1.PushAccountChange:
		go h.accountChange(mctx, cli, category, item)
		return true, nil
	default:
		if strings.HasPrefix(category, "stellar.") {
			return false, fmt.Errorf("unknown handler category: %q", category)
		}
		return false, nil
	}
}

func (h *Handler) Dismiss(ctx context.Context, cli gregor1.IncomingInterface, category string, item gregor.Item) (bool, error) {
	return false, nil
}

func (h *Handler) IsAlive() bool {
	return true
}
{'fraction_non_alphanumeric': 0.12073490813648294, 'fraction_numerical': 0.006707494896471274, 'mean_word_length': 5.259124087591241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2354133', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1196, 'n_words': 273}