Stubbing out DSL used to build disruptor.
diff --git a/TODO b/TODO
index df90ae2..fa5dfda 100644
--- a/TODO
+++ b/TODO
@@ -1,13 +1,8 @@
-- Wireup DSL
-
- Rewrite all code test first (including diamond pattern)
- Squeeze little bits of performance here and there by trying a few different things
e.g. pointers vs structs, padding, etc.
-- Cursors should probably all be created at the same time in wireup to keep them as close together as possible:
- https://news.ycombinator.com/item?id=7800825
-
- Integration suite that can exercise the Disruptor code on:
1. Multiple Go runtime versions, e.g. (1.1, 1.2, 1.3, etc.) (plus point releases and the latest tip)
2. Multiple CPU architectures: ARM, i386, AMD64
diff --git a/disruptor.go b/disruptor.go
new file mode 100644
index 0000000..df1f104
--- /dev/null
+++ b/disruptor.go
@@ -0,0 +1,28 @@
+package disruptor
+
+type Disruptor struct {
+ writer *Writer
+ readers []*Reader
+}
+
+func NewDisruptor(builder Builder) Disruptor {
+ // TODO: Cursors should probably all be created at the same time in wireup to keep them as close together as possible:
+ // https://news.ycombinator.com/item?id=7800825
+ return Disruptor{}
+}
+
+func (this Disruptor) Writer() *Writer {
+ return this.writer
+}
+
+func (this Disruptor) Start() {
+ for _, item := range this.readers {
+ item.Start()
+ }
+}
+
+func (this Disruptor) Stop() {
+ for _, item := range this.readers {
+ item.Stop()
+ }
+}
diff --git a/shared_disruptor.go b/shared_disruptor.go
new file mode 100644
index 0000000..fc3b501
--- /dev/null
+++ b/shared_disruptor.go
@@ -0,0 +1,26 @@
+package disruptor
+
+type SharedDisruptor struct {
+ writer *Writer
+ readers []*Reader
+}
+
+func NewSharedDisruptor(builder Builder) SharedDisruptor {
+ return SharedDisruptor{}
+}
+
+func (this SharedDisruptor) Writer() *Writer {
+ return this.writer
+}
+
+func (this SharedDisruptor) Start() {
+ for _, item := range this.readers {
+ item.Start()
+ }
+}
+
+func (this SharedDisruptor) Stop() {
+ for _, item := range this.readers {
+ item.Stop()
+ }
+}
diff --git a/wireup.go b/wireup.go
new file mode 100644
index 0000000..83a88b7
--- /dev/null
+++ b/wireup.go
@@ -0,0 +1,37 @@
+package disruptor
+
+type (
+ Wireup struct {
+ capacity int64
+ groups [][]Consumer
+ }
+)
+
+func Configure(capacity int64, consumers ...Consumer) Wireup {
+ this := Wireup{
+ capacity: capacity,
+ groups: [][]Consumer{},
+ }
+
+ return this.WithConsumerGroup(consumers...)
+}
+
+func (this Wireup) WithConsumerGroup(consumers ...Consumer) Wireup {
+ if len(consumers) == 0 {
+ return this
+ }
+
+ target := make([]Consumer, len(consumers))
+ copy(target, consumers)
+
+ this.groups = append(this.groups, target)
+ return this
+}
+
+func (this Wireup) Build() Disruptor {
+ return NewDisruptor(this)
+}
+
+func (this Wireup) BuildShared() SharedDisruptor {
+ return NewSharedDisruptor(this)
+}