Skip to content

Commit f080266

Browse files
committed
Update README.md
1 parent 847c665 commit f080266

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Wait()
132132

133133
### GenServers
134134

135-
quacktors supports Elixir style GenServers! And it even gets better: quacktors can even filter GenServer functions by operation and message type by parsing the methods name via reflection.
135+
As part of the default component set, quacktors supports Elixir style GenServers. The handlers for these are configured via the method names via reflection. So a GenServer with a `Call` handler for a `PrintRequest` would look like so:
136136

137137
```go
138138
type PrintRequest struct {
@@ -158,6 +158,8 @@ pid := Spawn(genserver.New(Printer{}))
158158
res, err := genserver.Call(pid, PrintRequest{})
159159
```
160160

161+
So you don't even have to write your own actors if you don't want to. Cool, isn't it?
162+
161163
### On message order and reception
162164

163165
In quacktors, message order is guaranteed from one actor to another. Meaning that if you send messages from A to B, they will arrive in order. The same is true for remote actors.

component/genserver/component.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,29 @@ import (
2626
//Casts are great when you only care about the actor receiving
2727
//a message but not if the operation was successful.
2828
//
29-
//The third and final way is a normal send. This is completely
30-
//asynchronous and acts like any other actor would (just that
31-
//a GenServer offers some more framework sugar to make it easier
32-
//to work with).
29+
//The third and final way is a normal send (the handlers for which
30+
//are postfixed with "Info"). This is completely asynchronous and
31+
//acts like any other actor would (just that a GenServer offers
32+
//some more framework sugar to make it easier to work with).
3333
//
3434
//Usage
3535
//
3636
//The handlers links for a custom GenServer are described via
3737
//the method names. The general format of a GenServer handler
3838
//is:
39-
// Handle + MessageType + (Call | Cast |or nothing for a send handler)
39+
// Handle + MessageType + (Call | Cast | Info)
4040
//So to handle a GenericMessage Cast, the method name would look
4141
//like so:
4242
// func (m myGenServer) HandleGenericMessageCast(ctx *Context, message GenericMessage)
43+
//
4344
//And a handler for a KillMessage Call would look like this:
4445
// func (m myGenServer) HandleKillMessageCall(ctx *Context, message KillMessage) Message
46+
//
4547
//A default handler for a DownMessage would look like this:
46-
// func (m myGenServer) HandleDownMessage(ctx *Context, message DownMessage)
48+
// func (m myGenServer) HandleDownMessageInfo(ctx *Context, message DownMessage)
49+
//
4750
//Note that the Call method returns a message, while the normal
48-
//send handler and the Cast handler don't. This is because
51+
//send handler (Info) and the Cast handler don't. This is because
4952
//a Call is the only GenServer operation that can directly return
5053
//something to the sender.
5154
//
@@ -54,8 +57,6 @@ import (
5457
// func (m myGenServer) HandleCast(ctx *Context, message GenericMessage)
5558
// func (m myGenServer) HandleCall(ctx *Context, message GenericMessage) Message
5659
// func (m myGenServer) HandleInfo(ctx *Context, message GenericMessage)
57-
//(HandleInfo is a innuendo to the Elixir GenServer and is
58-
//the "catch-all" for normal sends)
5960
type GenServer interface {
6061
InitGenServer(ctx *quacktors.Context)
6162
}

0 commit comments

Comments
 (0)