No description
Find a file
Christian Schaible 5742604629 Merged PR 716929: feat: Replace AMQP connection management
So far the SDK provided a messaging API that was not thread-safe (i.e. goroutine-safe). Additionally the SDK provided a MutexAPI which made it thread-safe at the cost of removed concurrency possibilities. The changes implemented in this commit replace both implementations with a thread-safe connection pool based solution.

The api gateway is a SDK user that requires reliable high performance send capabilities with a limit amount of amqp connections. These changes in the PR try address their requirements by moving the responsibility of connection management into the SDK. From this change other SDK users will benefit as well.

Security-concept-update-needed: false.

JIRA Work Item: STACKITALO-62
2025-01-27 13:23:54 +00:00
.azuredevops Merged PR 708047: chore: Update dependencies 2024-12-19 14:58:16 +00:00
audit Merged PR 716929: feat: Replace AMQP connection management 2025-01-27 13:23:54 +00:00
gen/go/audit/v1 Merged PR 708047: chore: Update dependencies 2024-12-19 14:58:16 +00:00
log Merged PR 680123: fix: Remove unnecessary interface pointers 2024-11-14 13:30:25 +00:00
proto Merged PR 672118: feat: Remove user provided trace-parent and trace-state 2024-11-04 13:55:10 +00:00
telemetry Merged PR 666097: feat: Add implementation of core library 2024-10-30 10:32:07 +00:00
.gitignore Merged PR 666097: feat: Add implementation of core library 2024-10-30 10:32:07 +00:00
audit-go.iml Merged PR 666097: feat: Add implementation of core library 2024-10-30 10:32:07 +00:00
buf.lock Merged PR 666097: feat: Add implementation of core library 2024-10-30 10:32:07 +00:00
go.mod Merged PR 708047: chore: Update dependencies 2024-12-19 14:58:16 +00:00
go.sum Merged PR 708047: chore: Update dependencies 2024-12-19 14:58:16 +00:00
README.md Merged PR 708047: chore: Update dependencies 2024-12-19 14:58:16 +00:00

audit-go

The audit-go library is the core library for validation and sending of audit events.

API Documentation

The api documentation can be found here.

Supported data types for routing

The following data types are currently supported for routing.

ObjectType Routable to customer Description
system no The STACKIT system
project yes STACKIT project
organization yes STACKIT organization
folder yes STACKIT folder

Additional API implementations

There's already an implementation draft of the api for the new dynamically routing audit log solution. As the implementation of the system has not officially been started yet, it's only a draft with integration tests. The API code is private to not confuse users or loose data until the new system is ready to be used.

The code can be found in the api_routable.go and api_routable_test.go files.

Development

Go

The current minimum toolchain version is go1.22.
The toolchain version can be set as environment variable (either manually in the terminal or in the ~/.basrc or ~/.zshrc):

export GOTOOLCHAIN=go1.22.7

Linter

The linter golangci-lint can either be installed via package manager (e.g. brew) or by running the following command in the terminal:

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2

Schema Generation

Go structs are generated from Protobuf schema by using Buf and some plugins.
The buf plugins are referenced in the proto/buf.gen.yaml file and are expected to be installed locally.
The schema generator also generates code to validate constraints specified in the schema.

Buf and the required plugins can either be installed via package manager (e.g. brew) or manually by running:

go install github.com/bufbuild/buf/cmd/buf@v1.47.2              #Pipeline: bufVersion
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.0 #Pipeline: protobufVersion,         go.mod: buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go 
go install github.com/envoyproxy/protoc-gen-validate@v1.1.0     #Pipeline: protobufValidateVersion, go.mod: google.golang.org/protobuf

Please check that the versions above match the versions in the go.mod file and the .azuredevops/build-pipeline.yml file.

Then the schema can be generated:

cd proto
buf generate

Build

The library can be built by executing the following commands:

go mod download && go mod tidy && go get ./... && go fmt ./... && go vet ./... && golangci-lint run && go build ./... && go test ./...
Testcontainers

To run the tests Docker is needed as Testcontainers is used to run integration tests using a solace docker container.

Register buf validation schema in IntelliJ / Goland

The schema files use Buf protobuf extensions for validation of constraints.

To register the schema in IntelliJ / Goland clone the repo and add the import path:

git clone https://github.com/bufbuild/protovalidate.git

IntelliJ/Goland > Settings > Languages & Frameworks > Protocol Buffers > Import Paths > + (Add Path) > …/protovalidate/proto/protovalidate