Skip to content

Commit

Permalink
restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
aliparlakci committed Feb 6, 2023
1 parent 219f1f4 commit 38c0740
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
11 changes: 11 additions & 0 deletions broadcast/broadcast.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package broadcast

type Configuration struct {
SelfAddress string
PeerAddresses []string
}

type Broadcaster interface {
Init() (chan []byte, error)
Broadcast([]byte) error
}
2 changes: 1 addition & 1 deletion communication.go → broadcast/communication.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gofret
package broadcast

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion communication_test.go → broadcast/communication_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gofret
package broadcast

import (
"testing"
Expand Down
7 changes: 1 addition & 6 deletions gofret.go → broadcast/fifo.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package gofret
package broadcast

import (
"encoding/json"
"fmt"
)

type FIFOBroadcaster interface {
Broadcaster
Wait() chan bool
}

type fifo_broadcast_message struct {
Address string // we should find another identifier since address for a node might not be same across nodes
SendSeq uint64
Expand Down
2 changes: 1 addition & 1 deletion gofret_test.go → broadcast/fifo_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gofret
package broadcast

import (
"math/rand"
Expand Down
12 changes: 1 addition & 11 deletions broadcast.go → broadcast/unordered.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gofret
package broadcast

type broadcast_container struct {
Communicator communicator
Expand All @@ -7,16 +7,6 @@ type broadcast_container struct {
messages chan []byte
}

type Configuration struct {
SelfAddress string
PeerAddresses []string
}

type Broadcaster interface {
Init() (chan []byte, error)
Broadcast([]byte) error
}

func (bc *broadcast_container) Connect(address string) {}

func (bc *broadcast_container) Broadcast(message []byte) error {
Expand Down
4 changes: 2 additions & 2 deletions broadcast_test.go → broadcast/unordered_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gofret
package broadcast

import (
"testing"
"time"
)

func TestBroadcast(t *testing.T) {
func TestUnorderedBroadcast(t *testing.T) {
peer_addrs := []string{"localhost:8881", "localhost:8882", "localhost:8883", "localhost:8884", "localhost:8885"}
message := "hello gofret!"

Expand Down

0 comments on commit 38c0740

Please sign in to comment.