-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdoc.go
66 lines (64 loc) · 1.97 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Tideland Go Cells
//
// Copyright (C) 2010-2017 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.
// Package cells is the main package of the Tideland Cells. They provide
// a framework for event and behavior based applications.
//
// Cell behaviors are defined based on an interface and can be added
// to an environment. Here they are running as concurrent cells that
// can be networked and communicate via events. Several useful behaviors
// are provided with the behaviors package.
//
// New environments are created with
//
// env := cells.NewEnvironment(identifier)
//
// and cells are added with
//
// env.StartCell("foo", NewFooBehavior())
//
// Cells then can be subscribed with
//
// env.Subscribe("foo", "bar")
//
// so that events emitted by the "foo" cell during the processing of
// events will be received by the "bar" cell. Each cell can have
// multiple cells subscibed.
//
// Events from the outside are emitted using
//
// env.Emit("foo", myEvent)
//
// or
//
// env.EmitNew("foo", "myTopic", cells.PayloadValues{
// "KeyA": 12345,
// "KeyB": true,
// })
//
// Behaviors have to implement the cells.Behavior interface. Here
// the Init() method is called with a cells.Context. This can be
// used inside the ProcessEvent() method to emit events to subscribers
// or directly to other cells of the environment.
//
// Sometimes it's needed to directly communicate with a cell to retrieve
// information. In this case the method
//
// response, err := env.RequestContext("foo", "myRequest?", myPayload, myTimeout)
//
// is to be used. Inside the ProcessEvent() of the addressed cell the
// event can be used to send the response with
//
// switch event.Topic() {
// case "myRequest?":
// event.Respond(someIncredibleData)
// case ...:
// ...
// }
//
// Instructions without a response are simply done by emitting an event.
package cells
// EOF