-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdad906
commit 3a4c65c
Showing
45 changed files
with
7,116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.23.x' | ||
- name: Install | ||
run: go get -v . | ||
- name: Build | ||
run: make build | ||
- name: Test | ||
run: make test TESTVERBOSE=-v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: golangci-lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
permissions: | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
# pull-requests: read | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.DS_store | ||
.*.swp | ||
.*.swo | ||
*.iml | ||
*.ipr | ||
*.iws | ||
*.sublime-* | ||
.direnv/ | ||
.gradle/ | ||
.idea/ | ||
.vscode/ | ||
*.prof | ||
.cov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
linters: | ||
enable: | ||
- bodyclose | ||
- errname | ||
- errorlint | ||
- exhaustive | ||
- goconst | ||
- gofmt | ||
- goimports | ||
- gocritic | ||
- predeclared | ||
- usestdlibvars | ||
- unused |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
As a contributor, you represent that the code you submit is your original work or that of your employer (in which case you represent you have the right to bind your employer). By submitting code, you (and, if applicable, your employer) are licensing the submitted code to LinkedIn and the open source community subject to the BSD 2-Clause license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BSD 2-CLAUSE LICENSE | ||
|
||
Copyright 2024 LinkedIn Corporation | ||
All Rights Reserved. | ||
|
||
Redistribution and use in source and binary forms, with or | ||
without modification, are permitted provided that the following | ||
conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
PACKAGE = github.com/linkedin/diderot | ||
SOURCE_FILES = $(wildcard $(shell git ls-files)) | ||
PROFILES = out | ||
COVERAGE = $(PROFILES)/diderot.cov | ||
GOBIN = $(shell go env GOPATH)/bin | ||
|
||
# "all" is invoked on a bare "make" call since it's the first recipe. It just formats the code and | ||
# checks that all packages can be compiled | ||
.PHONY: all | ||
all: fmt build | ||
|
||
build: | ||
go build -v ./... | ||
go test -v -c -o /dev/null $$(go list -f '{{if .TestGoFiles}}{{.ImportPath}}{{end}}' ./...) | ||
|
||
tidy: | ||
go mod tidy | ||
|
||
vet: | ||
go vet ./... | ||
|
||
$(GOBIN)/goimports: | ||
go install golang.org/x/tools/cmd/goimports@latest | ||
|
||
.PHONY: fmt | ||
fmt: $(GOBIN)/goimports | ||
$(GOBIN)/goimports -w . | ||
|
||
# Can be used to change the number of tests run, defaults to 1 to prevent caching | ||
TESTCOUNT = 1 | ||
# Can be used to change the verobosity of tests: make test TESTVERBOSE=-v | ||
TESTVERBOSE = | ||
# Can be used to generate coverage reports for a specific package | ||
COVERPKG = $(PACKAGE) | ||
# Can be used to change which package gets tested, defaults to all packages. | ||
TESTPKG = ./... | ||
|
||
test: $(COVERAGE) | ||
$(COVERAGE): | ||
@mkdir -p $(@D) | ||
go test -race -coverprofile=$(COVERAGE) -coverpkg=$(COVERPKG)/... -count=$(TESTCOUNT) $(TESTVERBOSE) $(TESTPKG) | ||
|
||
coverage: $(COVERAGE) | ||
go tool cover -html=$(COVERAGE) | ||
|
||
profile_cache: | ||
$(MAKE) -B $(PROFILES)/BenchmarkCacheThroughput.bench BENCH_PKG=./cache | ||
|
||
profile_handlers: | ||
$(MAKE) -B $(PROFILES)/BenchmarkHandlers.bench BENCH_PKG=./server | ||
|
||
BENCHCOUNT = 1 | ||
BENCHTIME = 1s | ||
|
||
$(PROFILES)/%.bench: | ||
ifdef BENCH_PKG | ||
$(eval BENCHBIN=$(PROFILES)/$*) | ||
mkdir -p $(PROFILES) | ||
go test -c \ | ||
-o $(BENCHBIN) \ | ||
./$(BENCH_PKG) | ||
cd $(BENCH_PKG) && $(BENCHBIN) \ | ||
-test.count $(BENCHCOUNT) \ | ||
-test.benchmem \ | ||
-test.bench="^$*$$" \ | ||
-test.cpuprofile $(PROFILES)/$*.cpu \ | ||
-test.memprofile $(PROFILES)/$*.mem \ | ||
-test.blockprofile $(PROFILES)/$*.block \ | ||
-test.benchtime $(BENCHTIME) \ | ||
-test.run "^$$" $(BENCHVERBOSE) \ | ||
. | tee $(abspath $@) $(abspath $(BENCHOUT)) | ||
else | ||
$(error BENCH_PKG undefined) | ||
endif | ||
ifdef OPEN_PROFILES | ||
go tool pprof $(BENCHBIN) $(PROFILES)/$*.cpu <<< web | ||
go tool pprof $(PROFILES)/$*.mem <<< web | ||
else | ||
$(info Not opening profiles since OPEN_PROFILES is not set) | ||
endif | ||
|
||
$(GOBIN)/pkgsite: | ||
go install golang.org/x/pkgsite/cmd/pkgsite@latest | ||
|
||
docs: $(GOBIN)/pkgsite | ||
$(GOBIN)/pkgsite -open . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Copyright 2024 LinkedIn Corporation | ||
All Rights Reserved. | ||
|
||
Licensed under the BSD 2-Clause License (the "License"). See License in the project root for license information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Diderot | ||
(pronounced dee-duh-row) | ||
|
||
--- | ||
|
||
Diderot is a server implementation of | ||
the [xDS protocol](https://www.envoyproxy.io/docs/envoy/latest/api-docs/xds_protocol) that makes it extremely easy and | ||
efficient to implement a control plane for your Envoy and gRPC services. For the most up-to-date information, please | ||
visit the [documentation](https://pkg.go.dev/github.com/linkedin/diderot). | ||
|
||
## Quick Start Guide | ||
The only thing you need to implement to make your resources available via xDS is a | ||
`diderot.ResourceLocator`([link](https://pkg.go.dev/github.com/linkedin/diderot#ResourceLocator)). It is the interface | ||
exposed by the [ADS server implementation](https://pkg.go.dev/github.com/linkedin/diderot#ADSServer) which should | ||
contain the business logic of all your resource definitions and how to find them. To facilitate this implementation, | ||
Diderot provides an efficient, low-resource [cache](https://pkg.go.dev/github.com/linkedin/diderot#Cache) that supports | ||
highly concurrent updates. By leveraging the cache implementation for the heavy lifting, you will be able to focus on | ||
the meaningful part of operating your own xDS control plane: your resource definitions. | ||
|
||
Once you have implemented your `ResourceLocator`, you can simply drop in a `diderot.ADSServer` to your gRPC service, and | ||
you're ready to go! Please refer to the [examples/quickstart](examples/quickstart/main.go) package | ||
|
||
## Features | ||
Diderot's ADS server implementation is a faithful implementation of the xDS protocol. This means it implements both the | ||
State-of-the-World and Delta/Incremental variants. It supports advanced features such as | ||
[glob collections](https://github.com/cncf/xds/blob/main/proposals/TP1-xds-transport-next.md#glob), unlocking the more | ||
efficient alternative to the `EDS` stage: `LEDS` | ||
([design doc](https://docs.google.com/document/d/1aZ9ddX99BOWxmfiWZevSB5kzLAfH2TS8qQDcCBHcfSE/edit#heading=h.mmb97owcrx3c)). | ||
|
Oops, something went wrong.