go-actor is a lightweight message framework using actor model

go-actor

  • go-actor is a lightweight message framework using actor model

初衷

  • 想能在代码逻辑上方便的写无锁的同步rpc调用代码,同时又不会阻塞住其他服务对这个Actor的调用
  • 一个Actor可以有多种身份,想能比较方便的分类管理Actor,分类通过Actor地址调用目标Actor
  • 节点间使用多种传输方式,比如游戏玩家移动这种同步可以使用tcp实现快速通知消息丢失也不太紧要,平台奖励类的可以使用mq通知

快速开始

  • 创建ActorSystem ActorSystem用来分类管理Actor,调用某个Actor的时候需要基于他所在的同名ActorSystem
    • go_actor.WithName: 指定ActorSystem名字,同类同名
    • go_actor.WithInstanceId: 指定节点id,同类型下唯一
    • go_actor.WithEtcd: etcd注册地址,同类型使用同组etcd
    • go_actor.WithTransport: 关联传输器
	system, err := go_actor.NewActorSystem(
		go_actor.WithName("hello"),
		go_actor.WithInstanceId(1),
		go_actor.WithEtcd("http://127.0.0.1:2379"),
		go_actor.WithTransport(trans),
	)
  • 创建执行器
    • SingleGoroutine: 单协程执行器,每个执行器同时只有一个协程在执行逻辑代码,当执行到Executer.Wait时会让出执行权给同执行器的其他协程处理消息,自己挂起直到Executer.OnResponse对应的session唤醒并等待其他协程让出执行权
	single := &executer.SingleGoroutine{}
	single.Start(context.Background(), 1)
  • 创建协议
    • protobuf
      • go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
      • go install github.com/lsg2020/go-actor/tools/protoc-gen-gactor
      • 定义协议文件例如
      • 生成 protoc -I . --go_out=. --gactor_out=. *.proto
	proto := protocols.NewProtobuf(1)
	hello.RegisterHelloService(&HelloService{}, proto)
  • 创建Actor并指定个名字注册到ActorSystem
	func (hello *HelloActor) OnInit(a go_actor.Actor) {
		hello.actor = a
		hello.addr = system.Register(a, "hello")
	}

	go_actor.NewActor(&HelloActor{}, single, go_actor.ActorWithProto(proto))
Similar Resources

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Jan 9, 2023

Trader is a framework that automated cryptocurrency exchange with strategy

Trader is a framework that automated cryptocurrency exchange with strategy

A framework that automated cryptocurrency exchange with strategy

Nov 29, 2022

Yu is a highly customizable blockchain framework.

Yu is a highly customizable blockchain framework.

禹 Yu is a highly customizable blockchain framework. 中文文档 Overall Structure Introduction By using Yu, you can customize three levels to develop your ow

Jan 7, 2023

Yu is a highly customizable blockchain framework.

Yu is a highly customizable blockchain framework.

禹 Yu is a highly customizable blockchain framework. 中文文档 Overall Structure Introduction By using Yu, you can customize three levels to develop your ow

Dec 11, 2022

Eunomia is a distributed application framework that support Gossip protocol, QuorumNWR algorithm, PBFT algorithm, PoW algorithm, and ZAB protocol and so on.

Introduction Eunomia is a distributed application framework that facilitates developers to quickly develop distributed applications and supports distr

Sep 28, 2021

The Cosmos-SDK is a framework for building blockchain applications in Golang.

The Cosmos-SDK is a framework for building blockchain applications in Golang.

The Cosmos-SDK is a framework for building blockchain applications in Golang. It is being used to build Gaia, the first implementation of the Cosmos Hub.

Nov 26, 2021

Eth-based smartcontracts framework

description status Advance EVM-Based framework development PENTA GO PENTA GO Is one of several PENTA ARCH services created to facilitate the developme

Dec 8, 2021

A simple, concurrent bitcoin miner framework implemented in Go.

Bitcoin Miner A simple, concurrent bitcoin miner framework implemented in Go. Disclaimer: this is not a product intended to be used for real mining, s

Dec 29, 2022

🌰 encrypt/decrypt using ssh keys

ssh-vault 🌰 encrypt/decrypt using ssh private keys Documentation https://ssh-vault.com Usage $ ssh-vault -h Example: $ echo "secret" | ssh-vault -u

Dec 30, 2022
A markov chain for Discord message dumps using https://github.com/fr3fou/polo

discord-markov-chain A markov chain for Discord message dumps using https://github.com/fr3fou/polo Download If you have a go installed, just clone the

Oct 28, 2022
A simple, secure self-destructing message service, using HashiCorp Vault product as a backend
A simple, secure self-destructing message service, using HashiCorp Vault product as a backend

sup3rS3cretMes5age! A simple, secure self-destructing message service, using Has

Mar 5, 2022
Peer-to-peer encrypted message exchange

Constellation Constellation is a self-managing, peer-to-peer system in which each node: Hosts a number of NaCl (Curve25519) public/private key pairs.

Nov 11, 2022
Tradingview-2-exchange - Place buy/sell orders in exchange(binance) when trading view strategy raise alert message

TradingView-2-Exchange This application is used to place a buy/sell order in Bin

Sep 27, 2022
An out-of-the-box cryptographic message communication.

An out-of-the-box cryptographic message communication.

Feb 8, 2022
A framework to build clusters using the hashicorp's raft implementation.
A framework to build clusters using the hashicorp's raft implementation.

Go - Rafting A framework to build clusters using the hashicorp's raft implementation. high quality video version Install go get -u github.com/danielga

Dec 10, 2022
A simple and lightweight encrypted password manager written in Go.
A simple and lightweight encrypted password manager written in Go.

Osiris Password Manager A simple and lightweight encrypted password manager written in Go

Jun 16, 2022
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀

cointop is a fast and lightweight interactive terminal based UI application for tracking and monitoring cryptocurrency coin stats in real-time.

Jan 6, 2023
TTAK.KO-12.0223 Lightweight Encryption Algorithm with Galois/Counter Mode (LEA-GCM)

LEACrypt The Lightweight Encryption Algorithm (also known as LEA) is a 128-bit block cipher developed by South Korea in 2013 to provide confidentialit

Dec 16, 2022
Berylbit PoW chain using Ethash, EPI-Burn and geth. The chain will be using bot congestion flashbot bundles through nodes

Berylbit PoW chain using Ethash, EPI-Burn and geth. The chain will be using bot congestion flashbot bundles through nodes. Soon, We will work towards

Jun 30, 2022