Skip to content

Instantly share code, notes, and snippets.

View mantzas's full-sized avatar
🏍️
hacking

Sotirios Mantziaris mantzas

🏍️
hacking
View GitHub Profile
package main
import "fmt"
type Customer struct {
Name string
}
func main() {
customers := []*Customer{{Name: "Oss"}}
@mantzas
mantzas / harvester.go
Created June 26, 2019 12:38
harvester usage field
func Process(name *sync.String) {
...
}
@mantzas
mantzas / harvester.go
Last active July 9, 2019 13:35
harvester usage struct
func Process(cfg *config) {
...
}
@mantzas
mantzas / harvester.go
Created June 4, 2019 19:34
harvester full
cfg := config{}
ii := []consul.Item{consul.NewKeyItem("harvester/example_03/balance")}
h, err := harvester.New(&cfg).
WithConsulSeed("127.0.0.1:8500", "", "", 0).
WithConsulMonitor("127.0.0.1:8500", "", "", 0, ii...).
Create()
if err != nil {
log.Fatalf("failed to create harvester: %v", err)
@mantzas
mantzas / harvester.go
Created June 4, 2019 18:55
harvester no monitor
cfg := config{}
h, err := harvester.New(&cfg).
WithConsulSeed("127.0.0.1:8500", "", "", 0).
Create()
if err != nil {
log.Fatalf("failed to create harvester: %v", err)
}
err = h.Harvest(ctx)
@mantzas
mantzas / harvester_noseed.go
Last active June 4, 2019 18:36
harvester instance
cfg := config{}
h, err := harvester.New(&cfg).Create()
if err != nil {
log.Fatalf("failed to create harvester: %v", err)
}
err = h.Harvest(ctx)
if err != nil {
log.Fatalf("failed to harvest configuration: %v", err)
type Config struct {
Name sync.String `seed:"John Doe"`
Age sync.Int64 `seed:"18" env:"ENV_AGE"`
IsAdmin sync.Bool `seed:"true" env:"ENV_IS_ADMIN" consul:"/config/is-admin"`
}
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/confluentinc/confluent-kafka-go/kafka"
beatkafka "github.com/taxibeat/go-toolkit/benchmarks/kafka"
public async Task<int> ProcessMessagesAsync(List<string> messages, IProgress<int> progress)
{
int totalCount = messages.Count;
int processCount = await Task.Run<int>(() =>
{
int tempCount = 0;
foreach (var message in messages)
{
Console.WriteLine(message);
if (progress != null)
public bool Run()
{
return true;
}
public Task<bool> RunAsync()
{
return Task.FromResult(true);
}