From 36edd74ebe263e9976b03da167734c5173367b0e Mon Sep 17 00:00:00 2001 From: Steve Yen Date: Tue, 28 Oct 2014 13:06:18 -0700 Subject: [PATCH] using public fields instead of getters --- feed_dcp.go | 6 +++--- feed_simple.go | 8 ++++---- feed_tap.go | 6 +++--- pindex_run.go | 20 ++++++++++---------- stream.go | 26 +++++++------------------- 5 files changed, 27 insertions(+), 39 deletions(-) diff --git a/feed_dcp.go b/feed_dcp.go index e786247..580134e 100644 --- a/feed_dcp.go +++ b/feed_dcp.go @@ -122,13 +122,13 @@ func (t *DCPFeed) feed() (int, error) { if uprEvent.Opcode == gomemcached.UPR_MUTATION { // TODO: Handle dispatch to streams correctly. t.streams[""] <- &StreamUpdate{ - id: uprEvent.Key, - body: uprEvent.Value, + Id: uprEvent.Key, + Body: uprEvent.Value, } } else if uprEvent.Opcode == gomemcached.UPR_DELETION { // TODO: Handle dispatch to streams correctly. t.streams[""] <- &StreamDelete{ - id: uprEvent.Key, + Id: uprEvent.Key, } } } diff --git a/feed_simple.go b/feed_simple.go index f983172..a61a2d5 100644 --- a/feed_simple.go +++ b/feed_simple.go @@ -87,21 +87,21 @@ func (t *SimpleFeed) feed() { switch req := req.(type) { case *StreamEnd: doneCh := make(chan error) - req.doneCh, doneChOrig = doneCh, req.doneCh + req.DoneCh, doneChOrig = doneCh, req.DoneCh wantWaitForClose = "source stream end" case *StreamFlush: doneCh := make(chan error) - req.doneCh, doneChOrig = doneCh, req.doneCh + req.DoneCh, doneChOrig = doneCh, req.DoneCh case *StreamRollback: doneCh := make(chan error) - req.doneCh, doneChOrig = doneCh, req.doneCh + req.DoneCh, doneChOrig = doneCh, req.DoneCh wantWaitForClose = "source stream rollback" case *StreamSnapshot: doneCh := make(chan error) - req.doneCh, doneChOrig = doneCh, req.doneCh + req.DoneCh, doneChOrig = doneCh, req.DoneCh case *StreamUpdate: case *StreamDelete: diff --git a/feed_tap.go b/feed_tap.go index 13d010c..c26d910 100644 --- a/feed_tap.go +++ b/feed_tap.go @@ -109,13 +109,13 @@ func (t *TAPFeed) feed() (int, error) { if op.Opcode == memcached.TapMutation { // TODO: Handle dispatch to streams correctly. t.streams[""] <- &StreamUpdate{ - id: op.Key, - body: op.Value, + Id: op.Key, + Body: op.Value, } } else if op.Opcode == memcached.TapDeletion { // TODO: Handle dispatch to streams correctly. t.streams[""] <- &StreamDelete{ - id: op.Key, + Id: op.Key, } } } diff --git a/pindex_run.go b/pindex_run.go index e9677e9..a2c8a4f 100644 --- a/pindex_run.go +++ b/pindex_run.go @@ -61,23 +61,23 @@ func RunBleveStream(mgr PIndexManager, pindex *PIndex, stream Stream, switch m := m.(type) { case *StreamUpdate: - bindex.Index(string(m.Id()), m.Body()) + bindex.Index(string(m.Id), m.Body) case *StreamDelete: - bindex.Delete(string(m.Id())) + bindex.Delete(string(m.Id)) case *StreamEnd: // Perhaps the datasource exited or is restarting? We'll // keep our stream open in case a new feed is hooked up. - if m.doneCh != nil { - close(m.doneCh) + if m.DoneCh != nil { + close(m.DoneCh) } case *StreamFlush: // TODO: Need to delete all records here. So, why not // implement this the same as rollback to zero? - if m.doneCh != nil { - close(m.doneCh) + if m.DoneCh != nil { + close(m.DoneCh) } case *StreamRollback: @@ -89,8 +89,8 @@ func RunBleveStream(mgr PIndexManager, pindex *PIndex, stream Stream, os.RemoveAll(pindex.Path) // First, respond to the feed so that it can unblock. - if m.doneCh != nil { - close(m.doneCh) + if m.DoneCh != nil { + close(m.DoneCh) } // Because, here the manager/janitor will synchronously @@ -101,8 +101,8 @@ func RunBleveStream(mgr PIndexManager, pindex *PIndex, stream Stream, case *StreamSnapshot: // TODO: Need to ACK some snapshot? - if m.doneCh != nil { - close(m.doneCh) + if m.DoneCh != nil { + close(m.DoneCh) } } } diff --git a/stream.go b/stream.go index 655cc7e..77840dc 100644 --- a/stream.go +++ b/stream.go @@ -20,48 +20,36 @@ type StreamRequest interface{} // ---------------------------------------------- type StreamEnd struct { - doneCh chan error + DoneCh chan error } // ---------------------------------------------- type StreamFlush struct { - doneCh chan error + DoneCh chan error } // ---------------------------------------------- type StreamRollback struct { - doneCh chan error + DoneCh chan error } // ---------------------------------------------- type StreamSnapshot struct { - doneCh chan error + DoneCh chan error } // ---------------------------------------------- type StreamUpdate struct { - id []byte - body []byte -} - -func (s *StreamUpdate) Id() []byte { - return s.id -} - -func (s *StreamUpdate) Body() []byte { - return s.body + Id []byte + Body []byte } // ---------------------------------------------- type StreamDelete struct { - id []byte -} - -func (s *StreamDelete) Id() []byte { - return s.id + Id []byte }