Skip to content

Commit 349e853

Browse files
committed
api: add initial implementation
The package parses constants from: - tarantool/src/box/errcode.h - tarantool/src/box/iproto_constants.h - tarantool/src/box/iproto_features.h You could to generate the code with the command: TT_TAG=master make Closes tarantool/go-tarantool#267
1 parent d382401 commit 349e853

23 files changed

+2622
-0
lines changed

.github/workflows/test.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: testing
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
tests:
10+
# We want to run on external PRs, but not on our own internal
11+
# PRs as they'll be run by the push to the branch.
12+
#
13+
# The main trick is described here:
14+
# https://github.com/Dart-Code/Dart-Code/pull/2375
15+
#
16+
# Also we want to run it always for manually triggered workflows.
17+
if: (github.event_name == 'push') ||
18+
(github.event_name == 'pull_request' &&
19+
github.event.pull_request.head.repo.full_name != github.repository) ||
20+
(github.event_name == 'workflow_dispatch')
21+
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
golang:
28+
- '1.13'
29+
- '1.20'
30+
31+
steps:
32+
- uses: actions/checkout@v3
33+
34+
- name: Setup golang ${{ matrix.golang }}
35+
uses: actions/setup-go@v3
36+
with:
37+
go-version: ${{ matrix.golang }}
38+
39+
- run: make test
40+
41+
master-build:
42+
if: (github.event_name == 'push') ||
43+
(github.event_name == 'pull_request' &&
44+
github.event.pull_request.head.repo.full_name != github.repository) ||
45+
(github.event_name == 'workflow_dispatch')
46+
47+
runs-on: ubuntu-latest
48+
49+
strategy:
50+
fail-fast: false
51+
52+
steps:
53+
- uses: actions/checkout@v3
54+
55+
- uses: actions/setup-go@v3
56+
57+
- run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
58+
59+
- run: make deps
60+
61+
- run: TT_TAG=master make
62+
63+
golangci-lint:
64+
if: (github.event_name == 'push') ||
65+
(github.event_name == 'pull_request' &&
66+
github.event.pull_request.head.repo.full_name != github.repository) ||
67+
(github.event_name == 'workflow_dispatch')
68+
69+
runs-on: ubuntu-latest
70+
71+
strategy:
72+
fail-fast: false
73+
74+
steps:
75+
- uses: actions/checkout@v3
76+
77+
- uses: actions/setup-go@v3
78+
79+
- name: golangci-lint
80+
uses: golangci/golangci-lint-action@v3
81+
continue-on-error: true
82+
with:
83+
# The first run is for GitHub Actions error format.
84+
args: -E goimports
85+
86+
- name: golangci-lint
87+
uses: golangci/golangci-lint-action@v3
88+
with:
89+
# The second run is for human-readable error format with a file name
90+
# and a line number.
91+
args: --out-${NO_FUTURE}format colored-line-number -E goimports

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
SHELL := /bin/bash
2+
3+
.PHONY: all
4+
all: generate test
5+
6+
.PHONY: deps
7+
deps:
8+
go install golang.org/x/tools/cmd/goimports@latest
9+
go install golang.org/x/tools/cmd/stringer@latest
10+
11+
.PHONY: format
12+
format:
13+
goimports -l -w .
14+
15+
.PHONY: generate
16+
generate:
17+
go generate ./...
18+
19+
.PHONY: test
20+
test:
21+
@echo "Running all packages tests"
22+
go clean -testcache
23+
go test -tags ./... -v -p 1

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[![Go Reference][godoc-badge]][godoc-url]
2+
[![Actions Status][actions-badge]][actions-url]
3+
[![Telegram][telegram-badge]][telegram-url]
4+
[![Telegram Russian][telegram-badge]][telegramru-url]
5+
6+
# iproto
7+
8+
## Import
9+
10+
```go
11+
import "github.com/tarantool/go-iproto"
12+
```
13+
14+
## Overview
15+
16+
Package `iproto` contains IPROTO constants.
17+
18+
The code generated from Tarantool code. Code generation is only supported for
19+
an actual commit/release. We do not have a goal to support all versions of
20+
Tarantool with a code generator.
21+
22+
## Example
23+
24+
```go
25+
package main
26+
27+
import (
28+
"fmt"
29+
30+
"github.com/tarantool/go-iproto"
31+
)
32+
33+
func main() {
34+
fmt.Printf("%s=%d\n", iproto.ER_READONLY, iproto.ER_READONLY)
35+
fmt.Printf("%s=%d\n", iproto.IPROTO_FEATURE_WATCHERS, iproto.IPROTO_FEATURE_WATCHERS)
36+
fmt.Printf("%s=%d\n", iproto.IPROTO_FLAG_COMMIT, iproto.IPROTO_FLAG_COMMIT)
37+
fmt.Printf("%s=%d\n", iproto.IPROTO_SYNC, iproto.IPROTO_SYNC)
38+
fmt.Printf("%s=%d\n", iproto.IPROTO_SELECT, iproto.IPROTO_SELECT)
39+
}
40+
```
41+
42+
## Development
43+
44+
You need to install `git` and `go1.13+` first. After that, you need to install
45+
additional dependencies into `$GOBIN`:
46+
47+
```bash
48+
make deps
49+
```
50+
51+
You can generate the code with commands:
52+
53+
```bash
54+
TT_TAG=master make
55+
TT_TAG=2.10.6 make
56+
TT_TAG=master TT_REPO=https://github.com/my/tarantool.git make
57+
```
58+
59+
You need to specify a target branch/tag with the environment variable `TT_TAG`
60+
and you could to specify a repository with the `TT_REPO`.
61+
62+
Makefile has additional targets that can be useful:
63+
64+
```bash
65+
make format
66+
TT_TAG=master make generate
67+
make test
68+
```
69+
70+
A good starting point is [generate.go](./generate.go).
71+
72+
[actions-badge]: https://github.com/tarantool/go-iproto/actions/workflows/test.yml/badge.svg
73+
[actions-url]: https://github.com/tarantool/go-iproto/actions/workflows/test.yml
74+
[godoc-badge]: https://pkg.go.dev/badge/github.com/tarantool/go-iproto.svg
75+
[godoc-url]: https://pkg.go.dev/github.com/tarantool/go-iproto
76+
[telegram-badge]: https://img.shields.io/badge/Telegram-join%20chat-blue.svg
77+
[telegram-url]: http://telegram.me/tarantool
78+
[telegramru-url]: http://telegram.me/tarantoolru

doc.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)