package
0.3.0
Repository: https://github.com/keecon/protoactor-go.git
Documentation: pkg.go.dev

# README

Proto.Actor Cluster - Virtual Actors (Alpha)

Massively distributed actors for GO

Proto.Actor supports the classic actor model also found in Erlang and Akka.
Our cluster support however uses a different approach, Virtual Actor Model.

This is a model where each actor appears to always exist. There is no lifecycle as in the classic actor model. You get a reference to the actor by asking for it's ID.

e.g.

hello := shared.GetHelloGrain("abc")
res := hello.SayHello(&shared.HelloRequest{Name: "Proto.Actor"})

This will ask the cluster where the 'abc' actor is located. If it does not yet exist, it will be created for you.

See Microsoft Orleans for more info about the Virtual Actor Model: http://dotnet.github.io/orleans/

How to

Protobuf IDL Definition

Start by defining your messages and grain contracts. You do this by using Protobuf IDL files.

Here is the definition from the /examples/cluster/shared example

syntax = "proto3";
package shared;

message HelloRequest {
  string name = 1;
}

message HelloResponse {
  string message = 1;
}

message AddRequest {
  double a = 1;
  double b = 2;
}

message AddResponse {
  double result = 1;
}

service Hello {
  rpc SayHello (HelloRequest) returns (HelloResponse) {} 
  rpc Add(AddRequest) returns (AddResponse) {}
}

Once you have this, you can generate your code using the protobuf protoc compiler.

Windows

#generate messages
protoc -I=. -I=%GOPATH%\src --gogoslick_out=. protos.proto
#generate grains 
protoc -I=. -I=%GOPATH%\src --gorleans_out=. protos.proto 

Implementing

Once the messages and contracts have been generated, you can start implementing your own business logic. This is essentially a type which is powered by a Proto.Actor actor behind the scenes.

package shared

// a Go struct implementing the Hello interface
type hello struct {
}

func (*hello) SayHello(r *HelloRequest) *HelloResponse {
	return &HelloResponse{Message: "hello " + r.Name}
}

func (*hello) Add(r *AddRequest) *AddResponse {
	return &AddResponse{Result: r.A + r.B}
}

// Register what implementation Proto.Actor should use when 
// creating actors for a certain grain type.
func init() {
	// apply DI and setup logic
	HelloFactory(func() Hello { return &hello{} })
}

Seed nodes

func main() {
    cluster.Start("127.0.0.1:7711")
    console.ReadLine()
}

Member nodes

func main() {
	cluster.Start("127.0.0.1:0", "127.0.0.1:7711")

    // get a reference to the virtual actor called "abc" of type Hello
	hello := shared.GetHelloGrain("abc")
	res := hello.SayHello(&shared.HelloRequest{Name: "Proto.Actor"})
	log.Printf("Message from grain %v", res.Message)
}

FAQ

Can I use Proto.Actor Cluster in production?

The Proto.Actor Cluster support is in alpha version, thus not production ready.

What about performance?

Proto.Actor Remoting is able to pass 1 million+ messages per second on a standard dev machine. This is the same infrastructure used in Proto.Actor cluster. Proto.Actor Cluster however uses an RPC API, meaning it is Request/Response in nature. If you wait for a response for each call, the throughput will ofcourse be a lot less. Async Fire and forget for performance, Request/Response for simplicity.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
goland:noinspection GoUnusedExportedFunction.
No description provided by the author
GetPubSub returns the PubSub extension from the actor system.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
creates a new ConsensusCheck value with the given data and return it back.
No description provided by the author
creates a new ConsensusChecks value and returns a pointer to it.
Create a new GetGossipStateRequest value and return it back.
No description provided by the author
Creates a new GossipActor and returns a pointer to its location in the heap.
No description provided by the author
Create a new SetGossipStateKey value with the given data and return it back.
No description provided by the author
No description provided by the author
NewKind creates a new instance of a kind.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewPublishingErrorDecision creates a new PublishingErrorDecision.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
RemotePlacementActor returns the PID of the remote placement actor.
RetryBatchAfter returns a new PublishingErrorDecision with the Delay set to the given duration.
No description provided by the author
No description provided by the author
No description provided by the author
WithBatchingProducerBatchSize sets maximum size of the published batch.
WithBatchingProducerLogThrottle sets a throttle for logging from this producer.
WithBatchingProducerMaxQueueSize set max size of the requests waiting in queue.
WithBatchingProducerOnPublishingError sets error handler that can decide what to do with an error when publishing a batch.
WithBatchingProducerPublisherIdleTimeout sets an optional idle timeout which will specify to the `IPublisher` how long it should wait before invoking clean up code to recover resources.
WithBatchingProducerPublishTimeout sets how long to wait for the publishing to complete.
WithClusterContextProducer sets the cluster context producer.
No description provided by the author
No description provided by the author
WithHeartbeatExpiration sets the gossip heartbeat expiration.
No description provided by the author
WithMaxNumberOfEventsInRequestLogThrottlePeriod sets the max number of events in request log throttled period.
WithPubSubSubscriberTimeout sets a timeout used when delivering a message batch to a subscriber.
WithRequestsLogThrottlePeriod sets the requests log throttle period.
WithRequestTimeout sets the request timeout.
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
Message was put in the queue of the subscriber.
Some other problem happened.
Message did not reach subscriber, because it was dead.
Delivery timed out.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Topic failed to forward the message.
Batch or message was successfully published according to the delivery guarantees.
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

Enum value maps for DeliveryStatus.
Enum value maps for DeliveryStatus.
FailBatchAndContinue skips the current batch and proceeds to the next one.
FailBatchAndStop causes the BatchingProducer to stop and fail the pending messages.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Enum value maps for IdentityHandoverAck_State.
Enum value maps for IdentityHandoverAck_State.
Enum value maps for PublishStatus.
Enum value maps for PublishStatus.
RetryBatchImmediately retries the current batch immediately.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Terminated, removed from lookup.
Started terminating, not yet removed from IIdentityLookup.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ClusterContextConfig is used to configure cluster context parameters.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
data structure helpful to store consensus check information and behavior.
No description provided by the author
acts as a storage of pointers to ConsensusCheck stored by key.
Defines a default cluster context hashBytes structure.
No description provided by the author
Message sent from topic to delivery actor.
EmptyKeyValueStore is a key value store that does nothing.
Used to query the GossipActor about a given key status.
Used by the GossipActor to send back the status value of a given key.
GetPid contains.
Actor used to send gossip messages around.
represents a value that can be sent in form of a delta change instead of a full value replace.
these are the entries of a delta value this can be seen as an array with data, where each element in the array is tagged with a sequence number.
The Gossiper data structure manages Gossip.
a known key might be heartbeat.
No description provided by the author
Ack a gossip request.
two GossipState objects can be merged key + member_id gets it's own entry, if collision, highest version is selected.
No description provided by the author
GossipUpdate Used to update gossip data when a ClusterTopology event occurs.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
request response call from Identity actor sent to each member asking what activations they hold that belong to the requester.
No description provided by the author
IdentityStorageLookup contains.
No description provided by the author
The Informer data structure implements the Gossip interface.
First request to initialize the actor.
No description provided by the author
Kind represents the kinds of actors a cluster can manage.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MemberList is responsible to keep track of the current cluster topology it does so by listening to changes from the ClusterProvider.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Message sent from delivery actor to topic to notify of subscribers that fail to process the messages.
Ack to the delivery actor after notification of subscribers that fail to process the messages.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PidResult contains.
ProduceProcessInfo is the context for a Produce call.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Publish ack/nack response.
No description provided by the author
No description provided by the author
Message posted to subscriber's mailbox, that is then unrolled to single messages, and has ability to auto respond See also PubSubAutoRespondBatch.
No description provided by the author
Message sent from publisher to topic actor See also PubSubBatch.
No description provided by the author
Contains message byte representation and type reference.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Mimic .NET ReenterAfterCancellation on GossipActor.
No description provided by the author
No description provided by the author
No description provided by the author
Used to setup Gossip Status Keys in the GossipActor.
Used by the GossipActor to respond SetGossipStatus requests.
No description provided by the author
SpawnLock contains.
StoredActivation contains.
Contains information about a failed delivery.
Sent to topic actor to add a subscriber.
Subscribe acknowledgement.
Identifies a subscriber by either ClusterIdentity or PID.
No description provided by the author
No description provided by the author
A list of subscribers.
No description provided by the author
No description provided by the author
Sent to topic actor to remove a subscriber.
Unsubscribe acknowledgement.

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
Context is an interface any cluster context needs to implement.
The Gossip interface must be implemented by any value that pretends to participate with-in the Gossip protocol.
This interface must be implemented by any value that wants to add or remove consensus checkers.
This interface must be implemented by any value that wants to react to cluster topology events.
This interface must be implemented by any value that.
No description provided by the author
IdentityLookup contains.
KeyValueStore is a distributed key value store.
No description provided by the author
No description provided by the author
No description provided by the author
StorageLookup contains.

# Type aliases

No description provided by the author
No description provided by the author
ConsensusChecker Customary type used to provide consensus check callbacks of any type note: this is equivalent to (for future go v1.18): type ConsensusChecker[T] func(GossipState, map[string]empty) (bool, T).
Defines a type to provide DefaultContext configurations / implementations.
Delivery status as seen by the delivery actor.
No description provided by the author
convenience type alias.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
customary type that defines a states sender callback.
No description provided by the author
No description provided by the author
PublishingErrorHandler decides what to do with a publishing error in BatchingProducer.
Status of the whole published batch or single message.