<commit_before>package kinetic

import (
	kproto "github.com/yongzhy/kinetic-go/proto"
)

type Callback interface {
	Failure()
	Done() bool
}

type MessageHandler interface {
	Handle(cmd *kproto.Command, value []byte) error
	Error()
	SetCallback(callback *Callback)
}

type SimpleCallback struct {
	done bool
}

func (c *SimpleCallback) Failure() {
	c.done = true
}

func (c *SimpleCallback) Done() bool {
	return c.done
}<commit_msg>add simple callback and handler<commit_after>package kinetic

import (
	kproto "github.com/yongzhy/kinetic-go/proto"
)

type Callback interface {
	Success()
	Failure()
	Done() bool
}

type MessageHandler interface {
	Handle(cmd *kproto.Command, value []byte) error
	Error()
	SetCallback(callback *Callback)
}

type SimpleCallback struct {
	done bool
}

func (c *SimpleCallback) Success() {
	c.done = true
}

func (c *SimpleCallback) Failure() {
	c.done = true
}

func (c *SimpleCallback) Done() bool {
	return c.done
}

type SimpleHandler struct {
	callback *Callback
}

func (h *SimpleHandler) Handle(cmd *kproto.Command, value []byte) error {
	if h.callback != nil {
		if cmd.Status != nil && cmd.Status.Code != nil {
			if cmd.GetStatus().GetCode() == kproto.Command_Status_SUCCESS {
				(*h.callback).Success()
			} else {
				(*h.callback).Failure()
			}
		}

	}
	return nil
}

func (h *SimpleHandler) Error() {

}

func (h *SimpleHandler) SetCallback(call *Callback) {
	h.callback = call
}
{'fraction_non_alphanumeric': 0.13156053184044786, 'fraction_numerical': 0.0, 'mean_word_length': 4.181159420289855, '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': '2909258', 'n_tokens_mistral': 513, 'n_tokens_neox': 488, 'n_words': 131}