Skip to content

Commit

Permalink
The new beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
sivakku committed Oct 24, 2016
0 parents commit 685242e
Show file tree
Hide file tree
Showing 20 changed files with 325 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .arcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"phabricator.uri": "https://code.uberinternal.com/",
"git.default-relative-commit": "origin/master"
}
31 changes: 31 additions & 0 deletions .arclint
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"linters": {
"golint": {
"type": "golint",
"include": "(\\.go$)",
"exclude": [
"(^Godeps/)",
"(^client/)",
"(/thrift/)"
]
},
"gofmt": {
"type": "gofmt",
"include": "(\\.go$)",
"exclude": [
"(^Godeps/)",
"(^client/)",
"(/thrift/)"
]
},
"govet": {
"type": "govet",
"include": "(\\.go$)",
"exclude": [
"(^Godeps/)",
"(^client/)",
"(/thrift/)"
]
}
}
}
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.out
*.test
*.xml
*.swp
.idea/
*.iml
*.cov
*.html
.tmp/
.gen/
/vendor
/minions
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "go-build"]
path = go-build
url = [email protected]:go-build
4 changes: 4 additions & 0 deletions .weaver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Please keep this file for tracking and modeling purposes.
sha: 0bae718f0d6dde06e4ed06b5fb474f2c5ef623ca
time: 1477350246
variant: variant_golang
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
PROJECT_ROOT = code.uber.internal/devexp/minions

# define the list of thrift files the service depends on
# (if you have some)
THRIFT_SRCS = idl/code.uber.internal/devexp/minions/minions.thrift

# list all executables
PROGS = minions

minions: $(wildcard *.go)

-include go-build/rules.mk

go-build/rules.mk:
git submodule update --init
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Documentation
To learn how to document your project on [EngDocs](https://engdocs.uberinternal.com), see this [guide](https://engdocs.uberinternal.com/engdocs/index.html).
19 changes: 19 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"code.uber.internal/go-common.git/x/log"
"code.uber.internal/go-common.git/x/metrics"
"code.uber.internal/go-common.git/x/tchannel"

jaeger "github.com/uber/jaeger-client-go/config"
)

type appConfig struct {
Logging log.Configuration
Metrics metrics.Configuration
Jaeger jaeger.Configuration
TChannel xtchannel.Configuration
Sentry log.SentryConfiguration
Verbose bool
ServiceName string `yaml:"serviceName"`
}
8 changes: 8 additions & 0 deletions config/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
serviceName: minions

logging:
level: info
stdout: true

jaeger:
disabled: false
21 changes: 21 additions & 0 deletions config/development.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add your development configuration here
tchannel:
# Use a fixed port during development.
port: 9876
# Use the local Hyperbahn nodes during development.
routers: ["127.0.0.1:21300", "127.0.0.1:21301"]

jaeger:
# This tells Jaeger to sample and capture every trace in the service.
# This section should not be in the production configuration,
# because it will degrade the application performance by reporting
# multiple spans per each request, and spam Jaeger with lots of data.
sampler:
type: "const"
param: 1
# The reporter settings ensure that each span is reported immediately
# as soon as it is finished (without being buffered), and its trace ID
# is written to the log.
reporter:
queueSize: 1
logSpans: true
13 changes: 13 additions & 0 deletions config/production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Add your production configuration here
logging:
stdout: true
kafka:
topic: minions

metrics:
m3:
hostPort: 127.0.0.1:9052
service: minions

sentry:
dsn: http://fill:[email protected]/fillmein
1 change: 1 addition & 0 deletions config/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Add your test configuration here
102 changes: 102 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package: code.uber.internal/devexp/minions
import:
- package: code.uber.internal/go-common.git
version: master
subpackages:
- x/config
- x/log
- x/metrics
- x/tchannel
- package: github.com/uber/tchannel-go
subpackages:
- thrift
testImport:
- package: github.com/stretchr/testify
subpackages:
- assert
1 change: 1 addition & 0 deletions go-build
Submodule go-build added at 181764
5 changes: 5 additions & 0 deletions idl/code.uber.internal/devexp/minions/minions.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace java com.uber.devexp.minions

service MyService {
string hello()
}
51 changes: 51 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package main

import (
gen "code.uber.internal/devexp/minions/.gen/go/minions"
"code.uber.internal/go-common.git/x/config"
"code.uber.internal/go-common.git/x/jaeger"
"code.uber.internal/go-common.git/x/log"
"github.com/uber/tchannel-go"
"github.com/uber/tchannel-go/thrift"
)

func main() {
var cfg appConfig
if err := config.Load(&cfg); err != nil {
log.Fatalf("Error initializing configuration: %s", err)
}
log.Configure(&cfg.Logging, cfg.Verbose)
log.ConfigureSentry(&cfg.Sentry)

metrics, err := cfg.Metrics.New()
if err != nil {
log.Fatalf("Could not connect to metrics: %v", err)
}
metrics.Counter("boot").Inc(1)

closer, err := xjaeger.InitGlobalTracer(cfg.Jaeger, cfg.ServiceName, metrics)
if err != nil {
log.Fatalf("Jaeger.InitGlobalTracer failed: %v", err)
}
defer closer.Close()

if _, err := cfg.TChannel.New(cfg.ServiceName, metrics, registerHandlers); err != nil {
log.Fatalf("TChannel.New failed: %v", err)
}

// If the server needs to listen on HTTP port, use dynamic port:
// port, _ := config.GetDynamicHTTPPort(cfg.Port)

// Block forever.
select {}
}

func registerHandlers(ch *tchannel.Channel, server *thrift.Server) {
server.Register(gen.NewTChanMyServiceServer(myHandler{}))
}

type myHandler struct{}

func (myHandler) Hello(ctx thrift.Context) (string, error) {
return "Hello World!", nil
}
13 changes: 13 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestHello(t *testing.T) {
handler := myHandler{}
_, err := handler.Hello(nil)
assert.NoError(t, err, "Handler failed")
}
3 changes: 3 additions & 0 deletions udeploy/pinocchio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
service_name: minions
network_protocol: tchannel
service_type: go
1 change: 1 addition & 0 deletions udeploy/symlink_secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COUNT ME IN, BRO

0 comments on commit 685242e

Please sign in to comment.