All Projects → pojol → braid-go

pojol / braid-go

Licence: MIT license
简单易用的微服务框架 | Ease used microservice framework

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to braid-go

lightstep-tracer-java
The Lightstep distributed tracing library for JRE
Stars: ✭ 46 (+35.29%)
Mutual labels:  opentracing
opentracing-metrics-tracer
Exports cross-process metrics via OpenTracing to Prometheus.
Stars: ✭ 13 (-61.76%)
Mutual labels:  opentracing
moqui-hazelcast
Moqui Framework tool component for Hazelcast, used for distributed async services, entity distributed cache invalidation, web session replication, and distributed cache (javax.cache)
Stars: ✭ 12 (-64.71%)
Mutual labels:  distributed-systems
smallrye-opentracing
An MicroProfile-OpenTracing implementation
Stars: ✭ 17 (-50%)
Mutual labels:  opentracing
command-pal
The hackable command palette for the web, inspired by Visual Studio Code.
Stars: ✭ 32 (-5.88%)
Mutual labels:  micro-framework
rce
Distributed, workflow-driven integration environment
Stars: ✭ 42 (+23.53%)
Mutual labels:  distributed-systems
hleb
PHP Micro-Framework HLEB
Stars: ✭ 58 (+70.59%)
Mutual labels:  micro-framework
adrenaline
A PSR-7 micro framework built on top of the Adroit middleware to speed up your development ;)
Stars: ✭ 31 (-8.82%)
Mutual labels:  micro-framework
Distributed-Algorithms
利用 Go 语言实现多种分布式算法
Stars: ✭ 53 (+55.88%)
Mutual labels:  distributed-systems
quartz-scheduler-hazelcast-jobstore
An implementation of a Quartz Scheduler JobStore using Hazelcast distributed Collections
Stars: ✭ 42 (+23.53%)
Mutual labels:  distributed-systems
socketcluster-client-python
Python client for socket-cluster framework in node.js
Stars: ✭ 47 (+38.24%)
Mutual labels:  pub-sub
nebula
A distributed, fast open-source graph database featuring horizontal scalability and high availability
Stars: ✭ 8,196 (+24005.88%)
Mutual labels:  distributed-systems
ucz-dfs
A distributed file system written in Rust.
Stars: ✭ 25 (-26.47%)
Mutual labels:  distributed-systems
amas
Amas is recursive acronym for “Amas, monitor alert system”.
Stars: ✭ 77 (+126.47%)
Mutual labels:  opentracing
commix
Micro-framework for data-driven composable system architectures
Stars: ✭ 46 (+35.29%)
Mutual labels:  micro-framework
microservices-demo
A Monorepo Demoing Microservices Architecture
Stars: ✭ 36 (+5.88%)
Mutual labels:  opentracing
aether
Distributed system emulation in Common Lisp
Stars: ✭ 19 (-44.12%)
Mutual labels:  distributed-systems
fabric
Fabric is an experimental protocol for exchanging information.
Stars: ✭ 46 (+35.29%)
Mutual labels:  distributed-systems
logserver
web log viewer that combines logs from several sources
Stars: ✭ 20 (-41.18%)
Mutual labels:  distributed-systems
go-distsys
Distributed Systems programming examples in the Go programming language.
Stars: ✭ 101 (+197.06%)
Mutual labels:  distributed-systems

Braid


Go Report Card CI Coverage Status

中文

Intro

Description of Service Node Module RPC Pub-sub

image.png


  • RPC Client/Server - Used for request / response from service to service
  • Pub-sub - Used to publish & subscribe messages from module to module
  • Discover - Automatic service discovery, and broadcast the node's entry, exit, update and other messages
  • Balancer - Client side load balancing which built on service discovery. Provide smooth weighted round-robin balancing by default
  • Elector - Select a unique master node for the same name service
  • Tracer - Distributed tracing system, used to monitor the internal state of the program running in microservices
  • Linkcache - Link cache used to maintain connection information in distributed systems

Quick start

b, _ := NewService("braid")

b.RegisterDepend(
	depend.Logger(),
	depend.Redis(redis.WithAddr(mock.RedisAddr)),
	depend.Tracer(
		tracer.WithHTTP(mock.JaegerAddr),
		tracer.WithProbabilistic(1),
	),
	depend.Consul(
		consul.WithAddress([]string{mock.ConsulAddr}),
	),
)

b.RegisterModule(
	module.Pubsub(
		pubsub.WithLookupAddr([]string{mock.NSQLookupdAddr}),
		pubsub.WithNsqdAddr([]string{mock.NsqdAddr}, []string{mock.NsqdHttpAddr}),
	),
	module.Client(
		client.AppendInterceptors(grpc_prometheus.UnaryClientInterceptor),
	),
	module.Server(
		server.WithListen(":14222"),
		server.AppendInterceptors(grpc_prometheus.UnaryServerInterceptor),
	),
	module.Discover(),
	module.Elector(
		elector.WithLockTick(3*time.Second)),
	module.LinkCache(
		linkcache.WithMode(linkcache.LinkerRedisModeLocal),
	),
)

b.Init()
b.Run()
defer b.Close()

Sample

  • RPC -
     err := braid.Client().Invoke(
     	ctx,
     	"target service name (login",
     	"methon (/login/guest",
     	"token (optional",
     	body,
     	res,
     )
  • Pubsub
     braid.Pubsub().LocalTopic("topic").Pub(*pubsub.Message)
    
     lc := braid.Pubsub().LocalTopic("topic").Sub("name")
     lc.Arrived(func(msg *pubsub.Message){ 
     	/* todo ... */ 
     })
     defer lc.Close()
    
     cc := braid.ClusterTopic("topic").Sub("name")
     cc.Arrived(func(msg *pubsub.Message){ 
     	/* todo ... */
     })
     defer cc.Close()
  • Tracer
     b.RegisterDepend(
     	depend.Tracer(
     		tracer.WithHTTP(jaegerAddr),
     		tracer.WithProbabilistic(jaegerProbabilistic),
     		tracer.WithSpanFactory(
     			tracer.TracerFactory{
     				Name:    mspan.Mongo,
     				Factory: mspan.CreateMongoSpanFactory(),
     			},
     		),
     	),
     )
    
     span := braid.Tracer().GetSpan(mspan.Mongo)
    
     span.Begin(ctx)
     defer span.End()
    
     // todo ...
     span.SetTag("key", val)

Pub-sub Benchmark

  • ScopeProc
$ go test -benchmem -run=^$ -bench ^BenchmarkTestProc -cpu 2,4,8
cpu: 2.2 GHz 4 Cores Intel Core i7
goos: darwin
goarch: amd64
pkg: github.com/pojol/braid-go/modules/mailboxnsq
BenchmarkTestProc-2   4340389   302 ns/op   109 B/op   3 allocs/op
BenchmarkTestProc-4   8527536   151 ns/op   122 B/op   3 allocs/op
BenchmarkTestProc-8   7564869   161 ns/op   118 B/op   3 allocs/op
PASS
  • ScopeCluster
$ go test -benchmem -run=^$ -bench ^BenchmarkClusterBroadcast -cpu 2,4,8
tencent cloud 4 Cores
goos: linux
goarch: amd64
BenchmarkClusterBroadcast-2   70556   17234 ns/op   540 B/op   16 allocs/op
BenchmarkClusterBroadcast-4   71202   18975 ns/op   676 B/op   20 allocs/op
BenchmarkClusterBroadcast-8   62098   19037 ns/op   662 B/op   20 allocs/op
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].