Skip to content

Inline Submodules Part 3 #466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2,334 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2334 commits
Select commit Hold shift + click to select a range
abf047e
Fix DescribeTable implementation
dsabeti Jan 3, 2024
3c58607
Add comments to clarify logic
dsabeti Jan 3, 2024
5d3a66a
Fix broken config test
dsabeti Jan 4, 2024
8d02259
Index attempts from 0 instead of 1
dsabeti Jan 4, 2024
2fd324b
Backfill test to validate existing behavior of 'overloaded' logic
dsabeti Jan 5, 2024
b43a34c
Use correct logger fake
dsabeti Jan 5, 2024
019b9de
Fix test description
dsabeti Jan 5, 2024
50676f7
Backfill tests to describe scenarios with endpoint errors
dsabeti Jan 8, 2024
ac758b6
When all AZ-local endpoints have errors, return the first endpoint (r…
dsabeti Jan 8, 2024
f50ed90
Fix broken test
jrussett Jan 9, 2024
bdf8020
Bugfix: only return nil when all endpoints are overloaded
dsabeti Jan 10, 2024
9023615
Remove unnecessary `rand.Seed()`
jrussett Jan 10, 2024
6a1714e
Add more descriptive comments in roundrobin
jrussett Jan 10, 2024
12ff0e6
Move curIsLocal calculation up for legibility
jrussett Jan 11, 2024
2f451b8
Clarify indexing logic
jrussett Jan 12, 2024
68b3bda
Declare variables in the scope where they're used
dsabeti Jan 18, 2024
b2d621c
Fix ability to start gorouter with the default config (#387)
geofffranks Jan 23, 2024
31a2bec
Protect against data race when ReverseProxy modifies response headers
mariash Jan 22, 2024
5da3cb9
Improve the ReverseProxy race condition test
mariash Jan 23, 2024
6e8fdda
feat: Use fixed port for local route services server. (#389)
domdom82 Jan 26, 2024
f090336
Add cipher-suites for TLS 1.3
winkingturtle-vmw Jan 29, 2024
064a5f0
Convert our processCipherSuites functionality to autogenerate (#391)
geofffranks Jan 29, 2024
ad6b877
Setup sticky session for Kerberos and NTML HTTP Authentication (#392)
mariash Feb 7, 2024
ef670d9
Add configuration flag to enable/disable sticky sessions for 'Authori…
geofffranks Feb 7, 2024
4097f31
feat: Log availability zone for endpoint (#394)
domdom82 Feb 12, 2024
9015251
feat: hack: support the "Partitioned" flag on VCAP_ID cookies
peanball Feb 20, 2024
9c55e9c
fix: Don't retry more often than endpoints available (#397)
domdom82 Feb 27, 2024
f0b4d8e
Enable full duplex mode for HTTP/1 requests
mariash Feb 15, 2024
1ac049c
Add an option to enable concurrent reads and writes for HTTP/1
mariash Feb 28, 2024
d16c7a7
fix: enable syslog config
domdom82 Feb 28, 2024
22f8d45
remove unnecessary sprintf
geofffranks Feb 27, 2024
198f637
Remove unnecessary sprintf
geofffranks Feb 27, 2024
0230997
SIGKILL can't be caught, but we might have wanted SIGQUIT here
geofffranks Feb 28, 2024
a030026
Simplify type conversions
geofffranks Feb 28, 2024
d671c0f
Stop using deprecated ioutil package
geofffranks Feb 29, 2024
583e3db
Remove deprecated PreferServerCipherSuties call (it is ignored now)
geofffranks Mar 1, 2024
8a9b340
Update gorouter to not have packages imported multiple times
geofffranks Feb 27, 2024
c3cea0d
range handles ranging over nil maps on its own
geofffranks Feb 27, 2024
6bb308e
Simplify Bytes to string conversion
geofffranks Feb 27, 2024
1e410d3
use raw strings with regexp definitions
geofffranks Feb 27, 2024
b7b9efa
remove unnecessary sprintf
geofffranks Feb 27, 2024
91a4f35
simplify redundant make args
geofffranks Feb 27, 2024
d8615ec
Simplify boolean
geofffranks Feb 27, 2024
e18c67a
simplify variable declaration
geofffranks Feb 27, 2024
825805a
Use fmt.Errorf() instead of errors.New() + fmt.Sprintf()
geofffranks Feb 27, 2024
fcdf60f
remove redundant returns
geofffranks Feb 27, 2024
ddbeca1
remove unneded selects
geofffranks Feb 27, 2024
812b465
Remove unnecessary sprintf
geofffranks Feb 27, 2024
69e7325
Remove unnecessary assignments to the blank identifier
geofffranks Feb 27, 2024
2e1f31c
Resolve a leak of timer.Tick() objects
geofffranks Feb 28, 2024
f3e74ba
Integer math resulted in 9/10 -> 0 vs 0.9 like the test desires
geofffranks Feb 28, 2024
5184f76
Convert value put into sync pool to be a pointer to avoid allocations
geofffranks Feb 28, 2024
e2114f3
EqualFold() is a more equal utf-8 comparison of case insensitivity
geofffranks Feb 28, 2024
e9166e8
Don't defer Close() before checking for errors
geofffranks Feb 28, 2024
375363b
don't save results of function calls that we don't use
geofffranks Feb 28, 2024
890e685
simplify variable declarations
geofffranks Feb 28, 2024
8e853db
Remove unused code
geofffranks Feb 28, 2024
b79fc2e
Stop using deprecated ioutil package
geofffranks Feb 29, 2024
39cdd4f
ignore deprecation warning for tlsconfig.RootCAs.Subjects() since we …
geofffranks Mar 1, 2024
5421e3b
Remove3 SSL3.0 test
geofffranks Mar 1, 2024
20b4e15
Fix deprecation warning for something we deprecated and haven't delet…
geofffranks Mar 1, 2024
6c6bd52
remove deprecated buildnametocertificate call
geofffranks Mar 1, 2024
1cf1c3c
Stop using deprecated httputil.ClientConn
geofffranks Mar 7, 2024
6f1bf4c
Remove use of net.Error's Temporary() function as it is deprecated an…
geofffranks Mar 7, 2024
e60aaf5
Remove deprecated ResponseWriter.CloseNotifier()
geofffranks Mar 7, 2024
79d1412
revert: remove deprecated buildnametocertificate call
maxmoehl Apr 3, 2024
4c57f5a
Add linter ignore for buidlnametocertificate
geofffranks Apr 3, 2024
32fffd5
Add availability zone to route registration message
mariash Apr 3, 2024
e7dfb8a
feat: Add TraceInfo to HTTPStartStop envelopes
mkocher Apr 3, 2024
63abcb6
Sync .github dir templates
tas-runtime-bot Apr 5, 2024
1c1b0bd
Sync .github dir templates
tas-runtime-bot Apr 5, 2024
6b9e162
Sync .github dir templates
tas-runtime-bot Apr 5, 2024
857cb08
Sync .github dir templates
tas-runtime-bot Apr 5, 2024
bcd8c7d
Sync .github dir templates
tas-runtime-bot Apr 5, 2024
95886f5
Sync .github dir templates
tas-runtime-bot Apr 5, 2024
c1010d3
Add test to validate cert name selection logic
geofffranks Apr 12, 2024
2ae1647
fix: unfocus cert test (#409)
maxmoehl Apr 17, 2024
d48b924
Use BeNil() since bump gomega 1.33.0 (#39)
winkingturtle-vmw Apr 22, 2024
0c89eb9
Send metric for requests with empty content length (#412)
mariash Apr 25, 2024
437047d
refactor: remove obsolete websocket handler
domdom82 Mar 8, 2024
fea57f9
refactor: update tests and code for websockets via stdlib
domdom82 Mar 8, 2024
0ac37d3
refactor: Code review
domdom82 Mar 26, 2024
35ae37e
fix: Compare using strings.EqualFold
domdom82 Mar 27, 2024
4a24b6a
TLS enabled healtchecks now support non-default ciphers (#413)
geofffranks May 2, 2024
07591e0
Report errors from health listener failures (#414)
geofffranks May 3, 2024
b54aeb2
fix(proxy): Read request before sending response in proxy test
domdom82 May 7, 2024
3fa4774
feat: Implement loadbalancing algo per route (#40)
b1tamara May 8, 2024
b9224db
Fix imports in messagebus_test
jrussett May 9, 2024
c8770de
Add test for checking 100 continues + non-200 response codes (#416)
geofffranks May 14, 2024
ad93972
Update to use newer signature for NewTcpRouteMapping function (#42)
geofffranks May 17, 2024
2cc511b
fix(reporter): check for empty content-length headers, if one is set
peanball May 22, 2024
959bd87
refactor(reporter): rename `missing_content_length_header` to `empty_…
peanball May 22, 2024
61c95ca
test(reporter): use the negroni handler to test empty_content_length_…
peanball May 22, 2024
0ebd989
Revert "Update to use newer signature for NewTcpRouteMapping function…
mariash May 24, 2024
a9a6160
Close backend connection when request expects 100-Continue (#418)
mariash May 24, 2024
6c7f637
Remove unused field
geofffranks May 24, 2024
9fc0d02
fix: remove unused field 'stopped', handle errors
peanball May 24, 2024
cec468b
Revert "Update to use newer signature for NewTcpRouteMapping function…
geofffranks May 24, 2024
18942c5
Revert to previous Director() based proxy logic for all requests that…
geofffranks May 24, 2024
467a3aa
Make nginx tests less flakey by waiting for the port to be up before …
geofffranks Jun 4, 2024
c58cdbb
fix: always validate route-service signature if present
maxmoehl May 28, 2024
57a141d
Limit unregistration messages to five
andy-a-d-nguyen Jun 3, 2024
9863c87
Revert "Revert "Update to use newer signature for NewTcpRouteMapping …
mariash Jun 6, 2024
2d14a35
With updated docs (#423)
winkingturtle-vmw Jun 11, 2024
bdd718f
With updated docs (#47)
winkingturtle-vmw Jun 11, 2024
122888a
fix: preserve x-forwarded-host for expect-100-continue req
maxmoehl Jun 14, 2024
603c677
Update 01-development-guide.md (#425)
jrussett Jun 19, 2024
eef846d
POC: make route registrar reload when there is a new config
tcdowney Jun 24, 2024
b8ca94c
Revert "POC: make route registrar reload when there is a new config"
ameowlia Jun 24, 2024
738eb09
Update route-registrar to handle *uint16 -> int conversion for HostTL…
Birdrock Jun 26, 2024
3dbb3b4
Ignore staticcheck SA1006 for fmt.Error(errMsg)
ebroberson Jul 3, 2024
8c9fa99
Replace codegangsta/cli with urfave/cli
nandy-vmware Jul 1, 2024
68dc5ff
Fix failing tests from TLS changes
ebroberson Jul 4, 2024
47bf957
Revert "Fix failing tests from TLS changes"
ameowlia Jul 11, 2024
cbe5f3f
Revert "Update route-registrar to handle *uint16 -> int conversion fo…
ameowlia Jul 11, 2024
8e45eed
Revert "Revert "Revert "Update to use newer signature for NewTcpRoute…
ameowlia Jul 11, 2024
d482b41
Per Route Load Balancing Algorithm
Dariquest Jul 9, 2024
2c35a7d
Per Route Load Balancing Algorithm Function Comment
Dariquest Jul 10, 2024
01c4189
Documentation of the logic
Dariquest Jul 11, 2024
7fa7c8a
Change public property LoadBalancingALgorithm to private and create g…
Dariquest Jul 11, 2024
3961b0b
Options in RegistryMessage, Struct for Options
Dariquest Jul 12, 2024
4d16021
Compare strings
Dariquest Jul 12, 2024
8b8c22f
Registry register method test
Dariquest Jul 15, 2024
f658ba0
Invalid load balancing alfgorithm was provided for a route test
Dariquest Jul 15, 2024
6b17585
Overwrite the pool algo with the last added route's one's
Dariquest Jul 15, 2024
a36ad68
Use default load balancing algorithm of a route registry
Dariquest Jul 15, 2024
e12b193
Add a pool property LBAlgorithm test
Dariquest Jul 15, 2024
e00eccc
Add a wrong lb algorithm log message
Dariquest Jul 15, 2024
1f0ec03
Test corresponding logging
Dariquest Jul 15, 2024
d60b334
Correct load balancing algorithm propagation from pool to the endpoints
Dariquest Jul 16, 2024
4a54c32
Default load balancing algo for tests
Dariquest Jul 16, 2024
97f1ac4
Add log message for overwriting load balancing algo and tests
Dariquest Jul 16, 2024
51737df
Refactoring
Dariquest Jul 16, 2024
a8a08a1
Add type check for the endpoints method
Dariquest Jul 16, 2024
60c5ae2
Test load balancing algorithm validator
Dariquest Jul 16, 2024
0bacb93
Log messages and eliminate endpoint lb algo property setter
Dariquest Jul 17, 2024
074ca55
Conversion of registry message options to an endpoint lb algo property
Dariquest Jul 17, 2024
444adfe
Review & Refactoring Extra Pool Method for LBOverwrite
Dariquest Jul 18, 2024
95bc0da
Rename pool.LBAlgorithm to pool.LoadBalancingAlgorithm
Dariquest Jul 18, 2024
79a1a5b
Add unit tests for the method OverrulePoolLoadBalancingAlgorithm
Dariquest Jul 19, 2024
dde03ad
Small test improvement
Dariquest Jul 19, 2024
c6c91ae
Removed forgotten code block
Dariquest Jul 19, 2024
8049d92
Documentation
Dariquest Jul 19, 2024
437d4f7
Comments corrected
Dariquest Jul 19, 2024
c0e36ae
Log message changes
Dariquest Jul 19, 2024
7fe57cd
Removing redundant test (struct init)
Dariquest Jul 19, 2024
cd9646a
Rename OverwriteLoadBalancingAlgo function
Dariquest Jul 19, 2024
97321ed
Removed explicit empty string spec
Dariquest Jul 19, 2024
1fd3db3
Removed explicit empty string spec test
Dariquest Jul 19, 2024
d79c0a2
Updates route-registrar to be aware of routing-api changes for handli…
geofffranks Jul 12, 2024
b3f0219
Update gorouter tests for go 1.22
geofffranks Aug 5, 2024
3cd25a5
Update metrics tests for go 1.22
geofffranks Aug 7, 2024
f0c5cb1
Add delay for gorouter integration test to fix flakes
geofffranks Aug 13, 2024
045a6ae
Replace nats deprecated DefaultOptions with GetDefaultOptions()
mariash Aug 13, 2024
3167187
Replace nats deprecated DefaultOptions with GetDefaultOptions()
Birdrock Aug 13, 2024
6823517
Address gosec rule G403
andy-a-d-nguyen Aug 20, 2024
54b44df
Support dynamic configuration for routes
mariash Aug 13, 2024
f5f7d25
Allow to configure host per route
mariash Aug 28, 2024
6331451
dep: bump gopkg.in/yaml to v3
maxmoehl Sep 6, 2024
ddd7228
dep: bump gopkg.in/yaml to v3 (#56)
maxmoehl Sep 6, 2024
7776313
Fix route YAML to match JSON (#57)
mariash Sep 11, 2024
8b0bcc7
Fix file/dir creation permissions
geofffranks Sep 13, 2024
6a21697
Upgrade zap; Replace logger interface with slog
hoffmaen Aug 21, 2024
28ec734
Reformat and reorder imports
hoffmaen Aug 30, 2024
d3b978e
Various fixes to logging and docs
hoffmaen Aug 30, 2024
9425914
fix(slog): only call complex log field population when level is enabled
peanball Sep 4, 2024
ff44964
Implement reflection-based struct logging; Fix address log
hoffmaen Sep 17, 2024
66da390
Use StructValue for logging struct values; Add checks to avoid panics…
hoffmaen Sep 18, 2024
8c4f7a4
Catch or explicitly ignore unhandled errors (#440)
geofffranks Sep 20, 2024
1603aa9
Catch or explicitly ignore unhandled errors
geofffranks Sep 16, 2024
38453e0
fix: remove partitioned cookie workaround (#441)
maxmoehl Sep 26, 2024
eb469a3
Merge branch 'main' into refactoring/zap-to-zapslog
hoffmaen Sep 27, 2024
334528c
Add logger to uptime monitor test
hoffmaen Sep 27, 2024
7bd6430
Log struct values: Read struct keys from json tag
hoffmaen Sep 30, 2024
9f678fd
Merge branch 'sap-contributions-refactoring/zap-to-zapslog'
ameowlia Sep 30, 2024
7097cd0
Fix test for logging tls-listener-started event
hoffmaen Sep 30, 2024
875c9b4
Fix memory leak from calling ifrit.Wait
hoffmaen Oct 14, 2024
e768fec
Properly calculate length of HTTP headers when evaluating max request…
geofffranks Oct 17, 2024
c76683b
Set ReadHeaderTimeout on gorouter and route-services servers
mariash Sep 17, 2024
ab2bc0c
Remove extra printf
geofffranks Oct 18, 2024
5174c18
Fix integration maxheader test for gorouter (#445)
geofffranks Oct 18, 2024
9ca6acc
add lb algorithm to endpoint JSON representation (#447)
a18e Oct 22, 2024
18da3a5
Restore Docs removed by sync-readme task (#446)
a18e Oct 25, 2024
1e0d864
Resolve G115 integer overflow warnings
geofffranks Oct 24, 2024
17116cb
Convert all port handling logic to uint16
geofffranks Oct 24, 2024
079f326
Sync README.md
tas-runtime-bot Oct 25, 2024
d74a450
Sync README.md
tas-runtime-bot Oct 25, 2024
c35a8cd
Remove outdated templates (#449)
winkingturtle-vmw Oct 28, 2024
ec6d861
Refactor for Zap 0.3 update
MarcPaquette Oct 28, 2024
e3d7611
Fix issues introduce when updating zap
MarcPaquette Oct 29, 2024
dc13429
fix: Enhance gorouter retry logic (#437)
b1tamara Oct 2, 2024
53fcecd
fix: Implement tests
b1tamara Oct 17, 2024
9ee77f4
test: Make test more readable
b1tamara Oct 23, 2024
e9ba2e1
fix: count repeated header keys for header limits
maxmoehl Nov 7, 2024
35e4728
refactor: MaxHeaderBytes -> MaxRequestHeaderBytes
maxmoehl Nov 7, 2024
8528055
feat: introduce custom response header limit
maxmoehl Nov 7, 2024
5c7e6c8
feat: configurable limits for header counts
maxmoehl Nov 8, 2024
2794143
fix capitalization
ameowlia Nov 18, 2024
aa6650d
Add new concurrency reference since the last one has been replaced by…
geofffranks Nov 19, 2024
c5c4002
feat: make syslog logging useable
maxmoehl Apr 19, 2024
2bd761b
fix: allow syslog-only logging
maxmoehl Apr 25, 2024
c6f5622
feat: replace log/syslog with internal version
maxmoehl Nov 20, 2024
c28ff7a
fix: rename testState.newRequest -> testState.newGetRequest
maxmoehl Dec 9, 2024
905ee53
test: add integration test for syslog access logs
maxmoehl Dec 9, 2024
8790f87
Revert "test: add integration test for syslog access logs"
ameowlia Dec 13, 2024
fe6cee4
Revert "fix: rename testState.newRequest -> testState.newGetRequest"
ameowlia Dec 13, 2024
b850412
Revert "feat: replace log/syslog with internal version"
ameowlia Dec 13, 2024
11c48bc
Revert "fix: allow syslog-only logging"
ameowlia Dec 13, 2024
d963f78
Revert "feat: make syslog logging useable"
ameowlia Dec 13, 2024
b610356
Syslog Improvements (2) (#459)
maxmoehl Dec 16, 2024
671ea98
extend logging
Dariquest Dec 17, 2024
2dd96da
Update registry.go
Dariquest Dec 17, 2024
c6b0bb1
fix go fmt
ameowlia Dec 19, 2024
c9fa52f
refactor: rename lb_algo to loadbalancing (#461)
a18e Jan 9, 2025
4ab8add
refactor: rename lb_algo to loadbalancing
a18e Dec 18, 2024
c713f55
Revert "refactor: rename lb_algo to loadbalancing (#461)"
ameowlia Jan 14, 2025
e4d2ffa
Revert "refactor: rename lb_algo to loadbalancing"
ameowlia Jan 14, 2025
a17697c
Tests for the fix
Dariquest Jan 7, 2025
b0d88bb
Revert "Revert "refactor: rename lb_algo to loadbalancing (#461)""
ameowlia Jan 17, 2025
96bc622
Revert "Revert "refactor: rename lb_algo to loadbalancing""
ameowlia Jan 17, 2025
a34e690
feat: log local TCP address
maxmoehl Nov 8, 2024
1e14fcf
fix(slog): disable automatic logging of stacktraces for errors
peanball Jan 31, 2025
3583c10
refactor: move timing info to extra access log fields logic
maxmoehl Feb 12, 2025
ccb3565
add X-CF-PROCESS-INSTANCE header that accepts guid:index
ameowlia Mar 17, 2025
cf2a7c0
allow X-CF-PROCESS-INSTANCE routing without index
ameowlia Mar 17, 2025
667463b
only compile regex matchers once
ameowlia Mar 18, 2025
272a76c
add different error message when index is not provided for process in…
ameowlia Mar 18, 2025
8ee00df
refactor: combine parse and vallidate header functions
ameowlia Mar 18, 2025
47ead2d
add unit test to show gorouter can use ecdsa certs
ameowlia Mar 20, 2025
caf8d6b
Report metrics via prometheus
b1tamara Feb 5, 2025
02baf47
feat: add new metrics interface and its implementation (for NATS and FD)
mike-jc Mar 12, 2025
5ddf9d9
doc: why we need zero value for Prometheus port
mike-jc Mar 12, 2025
b358720
refactor metric initialization
mike-jc Mar 13, 2025
73a80cb
fix: filter out nil argument when it is interface
mike-jc Mar 17, 2025
1114295
refactor: get rid of reflection
mike-jc Mar 18, 2025
93345ff
refactor: get rid of multiple interfaces
mike-jc Mar 18, 2025
957aaf4
refactor: remove unused method
mike-jc Mar 21, 2025
ffd637c
Revert "Protect against data race when ReverseProxy modifies response…
ameowlia Mar 27, 2025
dce6485
include gorouter_time metrics report
kart2bc Apr 7, 2025
85f72a0
fix non-constant format string in call to fmt.Errorf
ameowlia Apr 14, 2025
2f7165c
fix: move expensive map comparison to the end
maxmoehl Apr 10, 2025
92b53b0
fix: use proper way to compare timestamps
maxmoehl Apr 10, 2025
cbf385a
fix: add lb algo to comparison
maxmoehl Apr 10, 2025
e1b90dc
fix: move update of pool lb into Pool.Put
maxmoehl Apr 10, 2025
14cb282
test: add tests for updating the pool lb algo
maxmoehl Apr 10, 2025
b5be758
Retry new endpoint backends if they are being added while serving the…
mariash Apr 17, 2025
63df599
remove gorouter and route-registrar submodules
maxmoehl Apr 17, 2025
51d3bc2
Add 'src/code.cloudfoundry.org/route-registrar/' from commit '96bc622…
maxmoehl Apr 18, 2025
d88c0b3
Add 'src/code.cloudfoundry.org/gorouter/' from commit 'b5be7589592b9c…
maxmoehl Apr 18, 2025
b68fa10
adjust repository files after inlining
maxmoehl Apr 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 0 additions & 8 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,3 @@
path = src/code.cloudfoundry.org/routing-info
url = https://github.com/cloudfoundry/routing-info
branch = main
[submodule "src/code.cloudfoundry.org/gorouter"]
path = src/code.cloudfoundry.org/gorouter
url = https://github.com/cloudfoundry/gorouter
branch = main
[submodule "src/code.cloudfoundry.org/route-registrar"]
path = src/code.cloudfoundry.org/route-registrar
url = https://github.com/cloudfoundry/route-registrar
branch = main
273 changes: 273 additions & 0 deletions docs/01-gorouter-development-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
---
title: Development Guide
expires_at: never
tags: [ routing-release,gorouter ]
---

# Development Guide

## Reporting issues and requesting features

Please report all issues and feature requests in [cloudfoundry/routing-release](https://github.com/cloudfoundry/routing-release).

### Setup

Gorouter dependencies are managed with
[routing-release](https://github.com/cloudfoundry/routing-release#). Do not
clone the gorouter repo directly; instead, follow instructions at
https://github.com/cloudfoundry/routing-release#get-the-code (summarized below).

```bash
git clone https://github.com/cloudfoundry/routing-release
cd routing-release
./scripts/update
cd src/code.cloudfoundry.org/gorouter
```

### Running Tests

Tests in this repo cannot be run on their own, only as part of Routing Release.

Follow the instructions for [running tests in
docker](https://github.com/cloudfoundry/routing-release#in-a-docker-container)
in the routing release readme.

### Building

Building creates an executable in the gorouter/ dir:

```bash
go build
```

### Installing

Installing creates an executable in the $GOPATH/bin dir:

```bash
go install
```

### Start

```bash
# Start NATS server in daemon mode
git clone https://github.com/nats-io/nats-server
cd nats-server/
go install
nats-server &

# Start gorouter
gorouter
```

### Executables

1. `bin/test.bash`: This file is used to run test in Docker & CI and is not meant to be executed manually. Refer to the
[routing-release Contribution guide](https://github.com/cloudfoundry/routing-release/blob/develop/.github/CONTRIBUTING.md#running-tests) for more information.

## Recommended Reading

Recommended reading before diving into Gorouter code:

- [Hypertext Transfer Protocol](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Message_format)
- [How to use interfaces in Go](https://jordanorelli.com/post/32665860244/how-to-use-interfaces-in-go)
- [Golang Concurrency](https://go.dev/blog/pipelines)
- [http.Transport.RoundTrip](https://golang.org/pkg/net/http/#Transport.RoundTrip)
- [http.RoundTripper](https://golang.org/pkg/net/http/#RoundTripper)
- [http.ResponseWriter](https://golang.org/pkg/net/http/#ResponseWriter)
- [http.Request](https://golang.org/pkg/net/http/#Request)

- [Gorouter README.md](https://github.com/cloudfoundry/gorouter#gorouter)

## Golang TCP Networking Basics
Nearly all of the networking logic in Golang is dealt with the same pattern as
if one were dealing with a raw TCP connection.

Just as a general overview of how TCP networking works in Golang, let's go
through a sample set of applications that read and write from/to a TCP
connection.

Establishing a TCP connection requires a `Dial` from the client side and a
`Listen` on the server side. Since `Listen` can accept multiple simultaneous
connections, it must call `Accept` for every connection it handles.

Once you receive a `net.Conn` object to work with, there are three basic methods
on the `net.Conn` interface: `Read`, `Write`, and `Close`.

`Close` is self explanatory. `Read` and `Write` are blocking network calls that
block until some amount of data is read/written. They return error `io.EOF` when
the connection is closed. This is the only way to know whether or not a
connection has closed. Golang's HTTP package is no exception.

Basic client that subscribes and then prints what it receives:

```go
conn, err := net.Dial("tcp", "127.0.0.1:8080")
if err != nil {
// handle dial error
}
defer conn.Close()

_, err = conn.Write([]byte("subscribe"))
if err != nil {
// handle error writing to connection
}

tmpBuf := make([]byte, 1024)
for {
// conn.Read will block until some amount of data is read, and returns the
// number of bytes read along with an error. It will return bytes read as well
// as error `io.EOF` when data is received and the connection is closed, so be
// sure to process the data before handling `io.EOF`.
n, readErr := conn.Read(tmpBuf)
if n > 0 {
_, err := os.Stdout.Write(tmpBuf[:n])
if err != nil {
// handle error printing to standard out
}
}
if readErr == io.EOF {
// Connection has closed, so quit
break
} else {
// handle non-EOF read err
}
}

```

Basic server that checks for the subscribe message then sends the client info:

```go
ln, err := net.Listen("tcp", ":8080")
if err != nil {
// handle error
}
for {
conn, err := ln.Accept()
if err != nil {
// handle error
}
go handleConnection(conn)
}
...
func handleConnection(conn net.Conn) {
defer conn.Close()
tmpBuf := make([]byte, 16)
n, readErr := conn.Read(tmpBuf)
if readErr != nil {
// handle connection read err / connection close
}
if n == 9 && string(tmpBuf[:9]) == "subscribe" {
for i := 0; i < 5; i++ {
_, writeErr := conn.Write("hello")
if writeErr != nil {
// handle connection write err / connection close
}
}
} else {
// handle invalid read
}
}
```

Notice how this example demonstrates something similar to a HTTP `GET` request
and a response with body returned for that request. In fact, this is pretty much
how it's implemented in Golang's `net/http`, except it has a lot more logic to
follow the protocol.

Next time you use a http.ResponseWriter, think of it as a very thin wrapper on
top of `conn.Write` that only handles writing the HTTP headers for you.

## General Gorouter Architecture

Here is a general dependency graph (X-->Y means X is dependent on Y) for the
components of Gorouter.

![architecture](images/architecture.svg)

We'll go over some of these components later in this document, but this should
serve as a good starting point to where to start looking for the important
components of Gorouter.

`main.go` is also a good place to start looking to see how everything is
initialized. Notice that `nats-subscriber` and `route_fetcher` are initialized
in `main`, but they are depended on by the route registry.

## Ifrit processes

Here is the anatomy of an Ifrit process:

![ifrit](images/ifrit.svg)

Our Ifrit processes are used for long-running routines inside Gorouter, e.g.
serving HTTP requests with the router, or periodically fetching routes from
Routing API. There exist a few long-running processes in Gorouter that aren't
fully implemented with the Ifrit workflow. e.g. NATS subscriptions (mbus
package), and the route registry pruning cycle (registry package).

## What does Gorouter do?

It basically forwards requests from the client to backend instances of an app.

Here is a very basic depiction of what Gorouter does:
![basic request](images/basic_request.svg)

Route services are a bit tricky, but they involve two separate requests to the
route for the backend app through the Gorouter:
![route service request](images/routeservice.svg)

Here's a more detailed inspection of the request-response flow through the
Gorouter:
![indepth request](images/indepth_request.svg)

## What are all these extra components in the Gorouter request flow?

Most of the request processing logic lives in the [negroni
handlers](https://github.com/cloudfoundry/gorouter/blob/master/proxy/proxy.go).
Note that it usually isn't possible to implement any Response modification logic
in these handlers! That logic is mostly handled by the `ProxyRoundTripper`

Nearly all of the important logic is implemented as part of a
`ServeHTTP(http.ResponseWriter,*http.Request)` function.

### Negroni Handlers

1. `ProxyResponseWriter` augments the `ResponseWriter` with helpers and records
response body length

- https://github.com/cloudfoundry/gorouter/blob/master/handlers/proxywriter.go
- https://github.com/cloudfoundry/gorouter/blob/master/proxy/utils/responsewriter.go

1. [sets the `X-Vcap-Request-Id` header](https://github.com/cloudfoundry/gorouter/blob/master/handlers/request_id.go)
1. [records the request and response in the `access.log` file](https://github.com/cloudfoundry/gorouter/blob/master/handlers/access_log.go)
1. [reports response code and latency for metrics](https://github.com/cloudfoundry/gorouter/blob/master/handlers/reporter.go)
1. [responds to healthcheck requests](https://github.com/cloudfoundry/gorouter/blob/master/handlers/proxy_healthcheck.go)
1. [handles Zipkin headers](https://github.com/cloudfoundry/gorouter/blob/master/handlers/zipkin.go)
1. [checks HTTP protocol version](https://github.com/cloudfoundry/gorouter/blob/master/handlers/protocolcheck.go)
1. [**looks up backends for requested route**](https://github.com/cloudfoundry/gorouter/blob/master/handlers/lookup.go)
1. [determines whether the request should go to a route service](https://github.com/cloudfoundry/gorouter/blob/master/handlers/routeservice.go)
1. [handles TCP or WebSocket upgrade](https://github.com/cloudfoundry/gorouter/blob/master/proxy/proxy.go)
1. [**httputil.ReverseProxy** transforms the request into a request to the next hop](https://golang.org/src/net/http/httputil/reverseproxy.go?h=ReverseProxy#L28)

### ProxyRoundTripper

[ProxyRoundTripper](https://github.com/cloudfoundry/gorouter/blob/master/proxy/round_tripper/proxy_round_tripper.go)

This component executes the request to the next hop (whether it be to a backend
or to a route service).

Its responsibilities are:

1. Forwarding the request to either a backend or a route service (via the
`RoundTrip` method).
1. Retry failed requests.
1. Select the next endpoint in a set of backends for the requested route.
There are currently two different strategies for selecting the next
endpoint:: choose them in a Round Robin fashion, or choose the endpoint
with the least connections.
1. Setting trace headers on the response.
1. Setting sticky session cookies on the response. Sticky sessions are cookies
that allow clients to make requests to the same instance of the backend
app.
Loading