Skip to content

Commit

Permalink
Merge branch 'ydb-platform:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
vladDotH authored Dec 9, 2024
2 parents 85da81d + 9a4b4f8 commit 21b6d88
Show file tree
Hide file tree
Showing 48 changed files with 1,887 additions and 578 deletions.
17 changes: 17 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM mcr.microsoft.com/devcontainers/go:1-1.21-bookworm

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-pkg>

# Install golangci from GitHub. Binary will be $(go env GOPATH)/bin/golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2

# Install ydb cli from GitHub.
# COPY ./ydb /usr/local/bin/ydb
# RUN chmod +x /usr/local/bin/ydb

# [Optional] Uncomment the next lines to use go get to install anything else you need
# USER vscode
# RUN go get ...
# USER root
55 changes: 55 additions & 0 deletions .devcontainer/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3.8'

volumes:
ydb-data:
# driver: local
# driver_opts:
# type: tmpfs
# device: tmpfs
# o: size=80g
ydb-certs:

services:
sdk:
build:
context: .
dockerfile: Dockerfile

volumes:
- ydb-certs:/ydb_certs
- ../:/workspaces/ydb-go-sdk:cached

environment:
- YDB_VERSION=24.3
- YDB_CONNECTION_STRING=grpc://ydb:2136/local
- YDB_CONNECTION_STRING_SECURE=grpcs://ydb:2135/local
- YDB_ANONYMOUS_CREDENTIALS=1
- YDB_SSL_ROOT_CERTIFICATES_FILE=/ydb_certs/ca.pem

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:ydb

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

ydb:
image: ghcr.io/ydb-platform/local-ydb:24.3
restart: unless-stopped
hostname: ydb
platform: linux/amd64

volumes:
- ydb-data:/ydb_data
- ydb-certs:/ydb_certs

environment:
- YDB_USE_IN_MEMORY_PDISKS=true
- GRPC_TLS_PORT=2135
- GRPC_PORT=2136
- MON_PORT=8765

# Add "forwardPorts": [2135, 8765] to **devcontainer.json** to forward YDB locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
18 changes: 18 additions & 0 deletions .devcontainer/configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

if which ydb > /dev/null 2>&1; then
ENDPOINT=$(echo ${YDB_CONNECTION_STRING_SECURE:-$YDB_CONNECTION_STRING} | awk -F/ '{print $3}')
DATABASE=$(echo ${YDB_CONNECTION_STRING_SECURE:-$YDB_CONNECTION_STRING} | awk -F/ '{print "/" $4}')
CA_FILE_OPTION=""

if [ -n "$YDB_CONNECTION_STRING_SECURE" ]; then
CA_FILE_OPTION="--ca-file ${YDB_SSL_ROOT_CERTIFICATES_FILE}"
fi

ydb config profile create local \
--endpoint "$ENDPOINT" \
--database "$DATABASE" \
$CA_FILE_OPTION

ydb config profile activate local
fi
42 changes: 42 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go-postgres
{
"name": "Go & YDB",
"service": "sdk",
"dockerComposeFile": "compose.yml",
"workspaceFolder": "/workspaces/ydb-go-sdk",
// Allows the container to use ptrace, which is useful for debugging.
"capAdd": [
"SYS_PTRACE"
],
// Disables seccomp, which can be necessary for some debugging tools to function correctly.
"securityOpt": [
"seccomp=unconfined"
],
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"golang.go",
"VisualStudioExptTeam.vscodeintellicode",
"redhat.vscode-yaml",
"zxh404.vscode-proto3",
"github.vscode-github-actions"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [2135, 2136, 8765],
// Use 'initializeCommand' to run commands before the container is created.
"initializeCommand": "cd \"${localWorkspaceFolder}\" && git config --local user.email \"$(git config user.email)\" && git config --local user.name \"$(git config user.name)\"",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "go version && golangci-lint --version && go mod download",
// Use 'postStartCommand' to run commands after the container is started.
"postStartCommand": ".devcontainer/configure.sh"
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*.code-workspace
.vscode/*
.history/
.devcontainer
*.vsix
*.swp
*.exe
Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
## v3.94.0
* Refactored golang types mapping into ydb types using `ydb.ParamsFromMap` and `database/sql` query arguments
* Small breaking change: type mapping for `ydb.ParamsFromMap` and `database/sql` type `uuid.UUID` changed from ydb type `Text` to ydb type `UUID`

## v3.93.3
* Supported raw protobuf `*Ydb.TypedValue` using `ydb.ParamsBuilder()`

## v3.93.2
* Removed experimental helper `ydb.MustParamsFromMap`
* Changed result of experimental helper `ydb.ParamsFromMap` from tuple <`params.Parameters`, `error`> to `params.Parameters` only

## v3.93.1
* Published `query.ExecuteOption` as alias to `internal/query/options.Execute`

## v3.93.0
* Added `ydb.WithStaticCredentialsLogin` and `ydb.WithStaticCredentialsPassword` options

## v3.92.6
* Fixed string representation of `TzTimestamp`, `TzDatetime` and `TzDate` type values
* Added `database/sql/driver.Value` as type destination for almost ydb values

## v3.92.5
* Avoid retrying requests finished with 'UNAUTHORIZED' errors
* Avoid retrying requests finished with `UNAUTHORIZED` errors

## v3.92.4
* Fixed connections pool leak on closing

## v3.92.3
* Fixed error with incompleted data returen from transaction.ReadQueryResult method
* Fixed error with incompleted data return from transaction.ReadQueryResult method
* Added option `query/WithResponsePartLimitSizeBytes(...)` for queries with query service

## v3.92.2
Expand Down
21 changes: 11 additions & 10 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,7 @@ func ExampleOpen_advanced() {
fmt.Printf("connected to %s, database '%s'", db.Endpoint(), db.Name())
}

// func ExampleParamsMap
func ExampleMustParamsFromMap() {
func ExampleParamsFromMap() {
ctx := context.TODO()
db, err := ydb.Open(
ctx,
Expand All @@ -532,14 +531,16 @@ func ExampleMustParamsFromMap() {
fmt.Printf("connected to %s, database '%s'", db.Endpoint(), db.Name())

res, err := db.Query().QueryRow(ctx, `
DECLARE $textArg AS Text;
DECLARE $intArg AS Int64;
SELECT $textArg AS TextField, $intArg AS IntField
`, query.WithParameters(ydb.MustParamsFromMap(map[string]any{
"$textArg": "asd",
"$intArg": int64(123),
})))
DECLARE $textArg AS Text;
DECLARE $intArg AS Int64;
SELECT $textArg AS TextField, $intArg AS IntField
`,
query.WithParameters(ydb.ParamsFromMap(map[string]any{
"$textArg": "asd",
"$intArg": int64(123),
})),
)
if err != nil {
fmt.Printf("query failed")
}
Expand Down
Loading

0 comments on commit 21b6d88

Please sign in to comment.