Skip to content

Commit

Permalink
Spec (#277)
Browse files Browse the repository at this point in the history
* added glide for vendoring

* documented vendoring with glide

* updated vendored dependencies

* updated requirements docs
  • Loading branch information
xh3b4sd authored Nov 16, 2016
1 parent 3e34c61 commit 8bd49e7
Show file tree
Hide file tree
Showing 196 changed files with 16,284 additions and 810 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ gofmt:

gogenerate:
@go generate ./...
@protoc --proto_path=spec --go_out=plugins=grpc,import_path=text:client/interface/text/ spec/text_endpoint.proto
@protoc --proto_path=spec --go_out=plugins=grpc,import_path=text:service/endpoint/text/ spec/text_endpoint.proto
@protoc --proto_path=vendor/github.com/the-anna-project/spec/legacy --go_out=plugins=grpc,import_path=text:client/interface/text/ vendor/github.com/the-anna-project/spec/legacy/text_endpoint.proto
@protoc --proto_path=vendor/github.com/the-anna-project/spec/legacy --go_out=plugins=grpc,import_path=text:service/endpoint/text/ vendor/github.com/the-anna-project/spec/legacy/text_endpoint.proto

goget:
@# Setup workspace.
Expand Down
10 changes: 5 additions & 5 deletions annactl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync"

"github.com/spf13/cobra"
servicespec "github.com/xh3b4sd/anna/service/spec"
systemspec "github.com/xh3b4sd/anna/spec"
systemspec "github.com/the-anna-project/spec/legacy"
servicespec "github.com/the-anna-project/spec/service"
)

var (
Expand All @@ -24,7 +24,7 @@ func New() systemspec.Annactl {
type annactl struct {
// Dependencies.

serviceCollection servicespec.Collection
serviceCollection servicespec.ServiceCollection
textInterface systemspec.TextInterfaceClient

// Settings.
Expand Down Expand Up @@ -106,11 +106,11 @@ func (a *annactl) Metadata() map[string]string {
return a.metadata
}

func (a *annactl) Service() servicespec.Collection {
func (a *annactl) Service() servicespec.ServiceCollection {
return a.serviceCollection
}

func (a *annactl) SetServiceCollection(sc servicespec.Collection) {
func (a *annactl) SetServiceCollection(sc servicespec.ServiceCollection) {
a.serviceCollection = sc
}

Expand Down
28 changes: 14 additions & 14 deletions annactl/service_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ import (

kitlog "github.com/go-kit/kit/log"

servicespec "github.com/the-anna-project/spec/service"
"github.com/xh3b4sd/anna/service"
"github.com/xh3b4sd/anna/service/fs/mem"
"github.com/xh3b4sd/anna/service/id"
"github.com/xh3b4sd/anna/service/log"
"github.com/xh3b4sd/anna/service/permutation"
"github.com/xh3b4sd/anna/service/spec"
"github.com/xh3b4sd/anna/service/textinput"
"github.com/xh3b4sd/anna/service/textoutput"
)

func (a *annactl) newServiceCollection() spec.Collection {
func (a *annactl) newServiceCollection() servicespec.ServiceCollection {
// Set.
collection := service.NewCollection()

collection.SetFS(a.newFSService())
collection.SetID(a.newIDService())
collection.SetLog(a.newLogService())
collection.SetPermutation(a.newPermutationService())
collection.SetTextInput(a.newTextInputService())
collection.SetTextOutput(a.newTextOutputService())
collection.SetFSService(a.newFSService())
collection.SetIDService(a.newIDService())
collection.SetLogService(a.newLogService())
collection.SetPermutationService(a.newPermutationService())
collection.SetTextInputService(a.newTextInputService())
collection.SetTextOutputService(a.newTextOutputService())

collection.FS().SetServiceCollection(collection)
collection.ID().SetServiceCollection(collection)
Expand All @@ -37,30 +37,30 @@ func (a *annactl) newServiceCollection() spec.Collection {
}

// TODO make mem/os configurable
func (a *annactl) newFSService() spec.FS {
func (a *annactl) newFSService() servicespec.FSService {
return mem.New()
}

func (a *annactl) newIDService() spec.ID {
func (a *annactl) newIDService() servicespec.IDService {
return id.New()
}

func (a *annactl) newLogService() spec.Log {
func (a *annactl) newLogService() servicespec.LogService {
newService := log.New()

newService.SetRootLogger(kitlog.NewLogfmtLogger(kitlog.NewSyncWriter(os.Stderr)))

return newService
}

func (a *annactl) newPermutationService() spec.Permutation {
func (a *annactl) newPermutationService() servicespec.PermutationService {
return permutation.New()
}

func (a *annactl) newTextInputService() spec.TextInput {
func (a *annactl) newTextInputService() servicespec.TextInputService {
return textinput.New()
}

func (a *annactl) newTextOutputService() spec.TextOutput {
func (a *annactl) newTextOutputService() servicespec.TextOutputService {
return textoutput.New()
}
6 changes: 3 additions & 3 deletions annactl/text_interface.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package main

import (
systemspec "github.com/the-anna-project/spec/legacy"
servicespec "github.com/the-anna-project/spec/service"
"github.com/xh3b4sd/anna/client/interface/text"
servicespec "github.com/xh3b4sd/anna/service/spec"
systemspec "github.com/xh3b4sd/anna/spec"
)

// TODO text interface should be a service inside the service collection
func newTextInterface(newServiceCollection servicespec.Collection, gRPCAddr string) systemspec.TextInterfaceClient {
func newTextInterface(newServiceCollection servicespec.ServiceCollection, gRPCAddr string) systemspec.TextInterfaceClient {
newClient := text.New()
newClient.SetGRPCAddress(gRPCAddr)
newClient.SetServiceCollection(newServiceCollection)
Expand Down
12 changes: 6 additions & 6 deletions client/interface/text/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc"

systemspec "github.com/the-anna-project/spec/legacy"
objectspec "github.com/the-anna-project/spec/object"
servicespec "github.com/the-anna-project/spec/service"
"github.com/xh3b4sd/anna/object/networkresponse"
objectspec "github.com/xh3b4sd/anna/object/spec"
"github.com/xh3b4sd/anna/object/textoutput"
servicespec "github.com/xh3b4sd/anna/service/spec"
systemspec "github.com/xh3b4sd/anna/spec"
)

// New creates a new text interface service.
Expand All @@ -21,7 +21,7 @@ func New() systemspec.TextInterfaceClient {
type client struct {
// Dependencies.

serviceCollection servicespec.Collection
serviceCollection servicespec.ServiceCollection

// Settings.

Expand Down Expand Up @@ -68,15 +68,15 @@ func (c *client) EncodeRequest(textInput objectspec.TextInput) *StreamTextReques
return streamTextRequest
}

func (c *client) Service() servicespec.Collection {
func (c *client) Service() servicespec.ServiceCollection {
return c.serviceCollection
}

func (c *client) SetGRPCAddress(gRPCAddr string) {
c.gRPCAddr = gRPCAddr
}

func (c *client) SetServiceCollection(sc servicespec.Collection) {
func (c *client) SetServiceCollection(sc servicespec.ServiceCollection) {
c.serviceCollection = sc
}

Expand Down
4 changes: 2 additions & 2 deletions command/boot/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/spf13/cobra"

servicespec "github.com/the-anna-project/spec/service"
"github.com/xh3b4sd/anna/object/config"
servicespec "github.com/xh3b4sd/anna/service/spec"
)

// New creates a new boot command.
Expand All @@ -25,7 +25,7 @@ type Command struct {
// Dependencies.

configCollection *config.Collection
serviceCollection servicespec.Collection
serviceCollection servicespec.ServiceCollection

// Settings.

Expand Down
69 changes: 35 additions & 34 deletions command/boot/service_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/cenk/backoff"
kitlog "github.com/go-kit/kit/log"

objectspec "github.com/the-anna-project/spec/object"
servicespec "github.com/the-anna-project/spec/service"
"github.com/xh3b4sd/anna/service"
"github.com/xh3b4sd/anna/service/activator"
"github.com/xh3b4sd/anna/service/connection"
Expand All @@ -21,7 +23,6 @@ import (
"github.com/xh3b4sd/anna/service/network"
"github.com/xh3b4sd/anna/service/permutation"
"github.com/xh3b4sd/anna/service/random"
"github.com/xh3b4sd/anna/service/spec"
"github.com/xh3b4sd/anna/service/storage"
"github.com/xh3b4sd/anna/service/storage/memory"
"github.com/xh3b4sd/anna/service/storage/redis"
Expand All @@ -30,26 +31,26 @@ import (
"github.com/xh3b4sd/anna/service/tracker"
)

func (c *Command) newServiceCollection() spec.Collection {
func (c *Command) newServiceCollection() servicespec.ServiceCollection {
// Set.
collection := service.NewCollection()

collection.SetActivator(c.newActivatorService())
collection.SetConnection(c.newConnectionService())
collection.SetActivatorService(c.newActivatorService())
collection.SetConnectionService(c.newConnectionService())
collection.SetEndpointCollection(c.newEndpointCollection())
collection.SetFeature(c.newFeatureService())
collection.SetForwarder(c.newForwarderService())
collection.SetFS(c.newFSService())
collection.SetID(c.newIDService())
collection.SetInstrumentor(c.newInstrumentorService())
collection.SetLog(c.newLogService())
collection.SetNetwork(c.newNetworkService())
collection.SetPermutation(c.newPermutationService())
collection.SetRandom(c.newRandomService())
collection.SetFeatureService(c.newFeatureService())
collection.SetForwarderService(c.newForwarderService())
collection.SetFSService(c.newFSService())
collection.SetIDService(c.newIDService())
collection.SetInstrumentorService(c.newInstrumentorService())
collection.SetLogService(c.newLogService())
collection.SetNetworkService(c.newNetworkService())
collection.SetPermutationService(c.newPermutationService())
collection.SetRandomService(c.newRandomService())
collection.SetStorageCollection(c.newStorageCollection())
collection.SetTextInput(c.newTextInputService())
collection.SetTextOutput(c.newTextOutputService())
collection.SetTracker(c.newTrackerService())
collection.SetTextInputService(c.newTextInputService())
collection.SetTextOutputService(c.newTextOutputService())
collection.SetTrackerService(c.newTrackerService())

collection.Activator().SetServiceCollection(collection)
collection.Connection().SetServiceCollection(collection)
Expand All @@ -74,11 +75,11 @@ func (c *Command) newServiceCollection() spec.Collection {
return collection
}

func (c *Command) newActivatorService() spec.Activator {
func (c *Command) newActivatorService() servicespec.ActivatorService {
return activator.New()
}

func (c *Command) newConnectionService() spec.Connection {
func (c *Command) newConnectionService() servicespec.ConnectionService {
newService := connection.New()

newService.SetDimensionCount(c.configCollection.Space().Dimension().Count())
Expand All @@ -88,13 +89,13 @@ func (c *Command) newConnectionService() spec.Connection {
return newService
}

func (c *Command) newBackoffFactory() func() spec.Backoff {
return func() spec.Backoff {
func (c *Command) newBackoffFactory() func() objectspec.Backoff {
return func() objectspec.Backoff {
return backoff.NewExponentialBackOff()
}
}

func (c *Command) newEndpointCollection() spec.EndpointCollection {
func (c *Command) newEndpointCollection() servicespec.EndpointCollection {
newCollection := endpoint.NewCollection()

metricService := metric.New()
Expand All @@ -109,52 +110,52 @@ func (c *Command) newEndpointCollection() spec.EndpointCollection {
return newCollection
}

func (c *Command) newFeatureService() spec.Feature {
func (c *Command) newFeatureService() servicespec.FeatureService {
return feature.New()
}

func (c *Command) newForwarderService() spec.Forwarder {
func (c *Command) newForwarderService() servicespec.ForwarderService {
return forwarder.New()
}

// TODO make mem/os configurable
func (c *Command) newFSService() spec.FS {
func (c *Command) newFSService() servicespec.FSService {
return mem.New()
}

func (c *Command) newIDService() spec.ID {
func (c *Command) newIDService() servicespec.IDService {
return id.New()
}

func (c *Command) newInstrumentorService() spec.Instrumentor {
func (c *Command) newInstrumentorService() servicespec.InstrumentorService {
return prometheus.New()
}

func (c *Command) newLogService() spec.Log {
func (c *Command) newLogService() servicespec.LogService {
newService := log.New()

newService.SetRootLogger(kitlog.NewLogfmtLogger(kitlog.NewSyncWriter(os.Stderr)))

return newService
}

func (c *Command) newNetworkService() spec.Network {
func (c *Command) newNetworkService() servicespec.NetworkService {
return network.New()
}

func (c *Command) newPermutationService() spec.Permutation {
func (c *Command) newPermutationService() servicespec.PermutationService {
return permutation.New()
}

func (c *Command) newRandomService() spec.Random {
func (c *Command) newRandomService() servicespec.RandomService {
newService := random.New()

newService.SetBackoffFactory(c.newBackoffFactory())

return newService
}

func (c *Command) newStorageCollection() spec.StorageCollection {
func (c *Command) newStorageCollection() servicespec.StorageCollection {
newCollection := storage.NewCollection()

// Connection.
Expand Down Expand Up @@ -202,14 +203,14 @@ func (c *Command) newStorageCollection() spec.StorageCollection {
return newCollection
}

func (c *Command) newTextInputService() spec.TextInput {
func (c *Command) newTextInputService() servicespec.TextInputService {
return textinput.New()
}

func (c *Command) newTextOutputService() spec.TextOutput {
func (c *Command) newTextOutputService() servicespec.TextOutputService {
return textoutput.New()
}

func (c *Command) newTrackerService() spec.Tracker {
func (c *Command) newTrackerService() servicespec.TrackerService {
return tracker.New()
}
2 changes: 1 addition & 1 deletion connection-path/connection_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"encoding/json"
"math"

"github.com/the-anna-project/spec/legacy"
"github.com/xh3b4sd/anna/service/random"
"github.com/xh3b4sd/anna/spec"
)

// Config represents the configuration used to create a new connection path
Expand Down
2 changes: 1 addition & 1 deletion connection-path/connection_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/xh3b4sd/anna/spec"
"github.com/the-anna-project/spec/legacy"
)

func testMaybeNewConnectionPath(t *testing.T, coordinates [][]float64) spec.ConnectionPath {
Expand Down
5 changes: 3 additions & 2 deletions doc/development/requirements.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# requirements
To develop and run the project's unit tests there is only your favorite editor
To develop and run the project's unit tests there is only your favourite editor
and https://golang.org `>=go1.7` required.

There is a redis storage implementation. Using this, a running http://redis.io
instance is required. For convenience this can be run in a docker container.
Obviously, then, https://www.docker.com is required as well.
Obviously, then, https://www.docker.com is required as well. For vendoring
source code we use https://github.com/Masterminds/glide.
Loading

0 comments on commit 8bd49e7

Please sign in to comment.