<commit_before>package client

import (
	"github.com/miolini/bankgo/rpc/proto"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
)

type BalanceRecord struct {
	UserID int64
	Value  int64
}

type BalanceStorageClient struct {
	conn   *grpc.ClientConn
	client proto.BalanceStorageClient
}

func Connect(addr string) (*BalanceStorageClient, error) {
	conn, err := grpc.Dial(addr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}
	bsc := &BalanceStorageClient{}
	bsc.conn = conn
	bsc.client = proto.NewBalanceStorageClient(bsc.conn)
	return bsc, nil
}

func (bsc *BalanceStorageClient) Close() {
	bsc.conn.Close()
}

func (bsc *BalanceStorageClient) GetBalance(userID int64) (int64, error) {
	request := proto.GetRequest{UserId: userID}
	response, err := bsc.client.Get(context.Background(), &request)
	return response.Value, err
}

func (bsc *BalanceStorageClient) SetValue(userID int64, value int64) (int64, error) {
	request := proto.SetRequest{UserId: userID, Value: value}
	response, err := bsc.client.Set(context.Background(), &request)
	return response.Value, err
}

func (bsc *BalanceStorageClient) IncrementValue(userID int64, amount int64) (int64, error) {
	request := proto.IncrementRequest{UserId: userID, Amount: amount}
	response, err := bsc.client.Increment(context.Background(), &request)
	return response.Value, err
}

func (bsc *BalanceStorageClient) AllBalances() ([]BalanceRecord, error) {
	response, err := bsc.client.All(context.Background(), &proto.AllRequest{})
	if err != nil {
		return nil, err
	}
	result := make([]BalanceRecord, len(response.Records))
	for i := range response.Records {
		result[i] = BalanceRecord{response.Records[i].UserId, response.Records[i].Value}
	}
	return result, nil
}
<commit_msg>fix check err in rpc client<commit_after>package client

import (
	"github.com/miolini/bankgo/rpc/proto"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
)

type BalanceRecord struct {
	UserID int64
	Value  int64
}

type BalanceStorageClient struct {
	conn   *grpc.ClientConn
	client proto.BalanceStorageClient
}

func Connect(addr string) (*BalanceStorageClient, error) {
	conn, err := grpc.Dial(addr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}
	bsc := &BalanceStorageClient{}
	bsc.conn = conn
	bsc.client = proto.NewBalanceStorageClient(bsc.conn)
	return bsc, nil
}

func (bsc *BalanceStorageClient) Close() {
	bsc.conn.Close()
}

func (bsc *BalanceStorageClient) GetBalance(userID int64) (int64, error) {
	request := proto.GetRequest{UserId: userID}
	response, err := bsc.client.Get(context.Background(), &request)
	return response.Value, err
}

func (bsc *BalanceStorageClient) SetValue(userID int64, value int64) (int64, error) {
	request := proto.SetRequest{UserId: userID, Value: value}
	response, err := bsc.client.Set(context.Background(), &request)
	return response.Value, err
}

func (bsc *BalanceStorageClient) IncrementValue(userID int64, amount int64) (int64, error) {
	request := proto.IncrementRequest{UserId: userID, Amount: amount}
	response, err := bsc.client.Increment(context.Background(), &request)
	if err != nil {
		return 0, err
	}
	return response.Value, nil
}

func (bsc *BalanceStorageClient) AllBalances() ([]BalanceRecord, error) {
	response, err := bsc.client.All(context.Background(), &proto.AllRequest{})
	if err != nil {
		return nil, err
	}
	result := make([]BalanceRecord, len(response.Records))
	for i := range response.Records {
		result[i] = BalanceRecord{response.Records[i].UserId, response.Records[i].Value}
	}
	return result, nil
}

{'fraction_non_alphanumeric': 0.134669678147939, 'fraction_numerical': 0.011575381140598532, 'mean_word_length': 5.270796460176991, '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': '5407973', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1226, 'n_words': 285}