Skip to content

whitglint/protoactor-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

protoactor-cpp

Ultra-fast, distributed, cross-platform actors.

Proto.Actor

Source code

This is the C++ repository for Proto Actor.

(unstable/WIP)

Other implementations:

Requirements

  • C++14 compiler
  • Boost 1.53.0
  • CMake

How to build

protoactor-cpp is header-only.

protoactor-cpp uses and requires the CMake in order to build examples.

Design principles

Minimalistic API - The API should be small and easy to use. Avoid enterprisey containers and configurations.

Build on existing technologies - There are already a lot of great technologies for e.g. networking and clustering. Build on those instead of reinventing them. E.g. gRPC streams for networking, Consul for clustering.

Pass data, not objects - Serialization is an explicit concern - don't try to hide it. Protobuf all the way.

Be fast - Do not trade performance for magic API trickery.

Getting started

The best place currently for learning how to use Proto.Actor is the examples.

Hello world

Define a message type:

class Hello : public Message
{
public:
    Hello(const std::string &who) : who(who) {}

    std::string who;
};

Define an actor:

class HelloActor : public IActor
{
public:
    virtual void receive(const IContext &context) override
    {
        auto message = context.message();
        if (auto h = dynamic_cast<Hello *>(message.get())) {
            std::cout << "Hello " << h->who << std::endl;
        }
    }
};

Spawn it and send a message to it:

auto props = Actor::from_producer([]() { return std::make_unique<HelloActor>(); });
auto pid = Actor::spawn(*props);
pid->tell<Hello>("ProtoActor");

You should see the output Hello ProtoActor.

About

Proto Actor - Ultra fast distributed actors for C++

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages