<commit_before>package main

import (
	"context"
	"os"
	"strconv"
	"time"

	"github.com/rs/zerolog/log"
	"github.com/wzhliang/xing"
	"github.com/wzhliang/xing/examples/hello"
)

func _assert(err error) {
	if err != nil {
		log.Error().Msgf("Client: %v", err)
	}
}

func _assertReturn(req, resp string) {
	if req != resp {
		log.Error().Msgf("Client: %s != %s", req, resp)
	}
}

func main() {
	url := "amqp://guest:guest@localhost:5672/"
	mq := os.Getenv("RABBITMQ")
	if mq == "" {
		mq = url
	}
	producer, err := xing.NewClient("orchestration.controller", mq,
		xing.SetIdentifier(&xing.RandomIdentifier{}),
		xing.SetSerializer(&xing.JSONSerializer{}),
	)
	if err != nil {
		log.Error().Msg("failed to create new client")
		return
	}

	cli := hello.NewGreeterClient("host.server", producer)
	n, err := strconv.Atoi(os.Args[1])
	if err != nil {
		log.Error().Str("#", os.Args[1]).Msg("Wrong argument")
	}

	for i := 0; i < n; i++ {
		ctx, cancel := context.WithTimeout(context.Background(), 5000*time.Millisecond)
		ret, err := cli.Hello(ctx, &hello.HelloRequest{
			Name: "鸠摩智",
		})
		_assert(err)
		if err == nil {
			_assertReturn("yo", ret.Greeting)
		}
		cancel()

		ctx, cancel = context.WithTimeout(context.Background(), 5000*time.Millisecond)
		_, err = cli.Nihao(ctx, &hello.HelloRequest{
			Name: "虚竹",
		})
		_assert(err)
		cancel()

		ctx, cancel = context.WithTimeout(context.Background(), 5000*time.Millisecond)
		ret, err = cli.Hello(ctx, &hello.HelloRequest{
			Name: "王语嫣",
		})
		_assert(err)
		if err == nil {
			_assertReturn("美女好", ret.Greeting)
		}
		cancel()

		ctx, cancel = context.WithTimeout(context.Background(), 5000*time.Millisecond)
		ret, err = cli.Hello(ctx, &hello.HelloRequest{
			Name: "段誉",
		})
		_assert(err)
		if err == nil {
			_assertReturn("陛下好", ret.Greeting)
		}
		cancel()

		time.Sleep(1 * time.Second)
	}

}
<commit_msg>updating non threaded client example<commit_after>package main

import (
	"context"
	"fmt"
	"os"
	"strconv"
	"sync"
	"time"

	"github.com/rs/zerolog/log"
	"github.com/wzhliang/xing"
	"github.com/wzhliang/xing/examples/hello"
)

var success = 0
var m sync.Mutex

func _assert(err error) {
	if err != nil {
		log.Error().Msgf("Client: %v", err)
	}
}

func _assertReturn(req, resp string) {
	if req != resp {
		log.Error().Msgf("Client: %s != %s", req, resp)
	}
	success++
}

func main() {
	url := "amqp://guest:guest@localhost:5672/"
	mq := os.Getenv("RABBITMQ")
	if mq == "" {
		mq = url
	}
	producer, err := xing.NewClient("orchestration.controller", mq,
		xing.SetIdentifier(&xing.RandomIdentifier{}),
		xing.SetSerializer(&xing.JSONSerializer{}),
	)
	if err != nil {
		log.Error().Msg("failed to create new client")
		return
	}

	cli := hello.NewGreeterClient("host.server", producer)
	n, err := strconv.Atoi(os.Args[1])
	if err != nil {
		log.Error().Str("#", os.Args[1]).Msg("Wrong argument")
	}

	for i := 0; i < n; i++ {
		ctx, cancel := context.WithTimeout(context.Background(), 5000*time.Millisecond)
		ret, err := cli.Hello(ctx, &hello.HelloRequest{
			Name: "鸠摩智",
		})
		_assert(err)
		if err == nil {
			_assertReturn("yo", ret.Greeting)
		}
		cancel()

		ctx, cancel = context.WithTimeout(context.Background(), 5000*time.Millisecond)
		ret, err = cli.Hello(ctx, &hello.HelloRequest{
			Name: "王语嫣",
		})
		_assert(err)
		if err == nil {
			_assertReturn("美女好", ret.Greeting)
		}
		cancel()

		ctx, cancel = context.WithTimeout(context.Background(), 5000*time.Millisecond)
		ret, err = cli.Hello(ctx, &hello.HelloRequest{
			Name: "段誉",
		})
		_assert(err)
		if err == nil {
			_assertReturn("陛下好", ret.Greeting)
		}
		cancel()
		time.Sleep(1 * time.Millisecond)
	}
	fmt.Printf("success=%d\n", success)
	if success != n*3 {
		fmt.Printf("test failed")
	}

	producer.Close()
}

{'fraction_non_alphanumeric': 0.18339100346020762, 'fraction_numerical': 0.01224381155177003, 'mean_word_length': 3.8303341902313623, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5959458', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1515, 'n_words': 286}