Compare commits

..

No commits in common. "v3" and "v3.4.1" have entirely different histories.
v3 ... v3.4.1

19 changed files with 417 additions and 418 deletions

View File

@ -1,8 +0,0 @@
---
name: Question
about: Ask a question about micro
title: ''
labels: ''
assignees: ''
---

View File

@ -1,28 +0,0 @@
name: "autoapprove"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
workflow_run:
workflows: ["prbuild"]
types:
- completed
permissions:
pull-requests: write
contents: write
jobs:
autoapprove:
runs-on: ubuntu-latest
steps:
- name: approve
run: [ "curl -o tea https://dl.gitea.com/tea/main/tea-main-linux-amd64",
"chmod +x ./tea",
"./tea login add --name unistack --token ${{ secrets.GITHUB_TOKEN }} --url https://git.unistack.org",
"./tea pr --repo ${{ github.event.repository.name }}"
]
if: github.actor == 'vtolstov'
id: approve
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,29 +0,0 @@
name: lint
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- master
- v3
- v4
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
filter: 'blob:none'
- name: setup go
uses: actions/setup-go@v5
with:
cache-dependency-path: "**/*.sum"
go-version: 'stable'
- name: setup deps
run: go get -v ./...
- name: run lint
uses: https://github.com/golangci/golangci-lint-action@v6
with:
version: 'latest'

View File

@ -1,34 +0,0 @@
name: test
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- master
- v3
- v4
push:
branches:
- master
- v3
- v4
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
with:
filter: 'blob:none'
- name: setup go
uses: actions/setup-go@v5
with:
cache-dependency-path: "**/*.sum"
go-version: 'stable'
- name: setup deps
run: go get -v ./...
- name: run test
env:
INTEGRATION_TESTS: yes
run: go generate ./...

View File

@ -1,6 +1,6 @@
---
name: Bug report
about: For reporting bugs in micro
about: For reporting bugs in go-micro
title: "[BUG]"
labels: ''
assignees: ''
@ -16,3 +16,9 @@ assignees: ''
**How to reproduce the bug:**
If possible, please include a minimal code snippet here.
**Environment:**
Go Version: please paste `go version` output here
```
please paste `go env` output here
```

View File

@ -1,6 +1,6 @@
---
name: Feature request / Enhancement
about: If you have a need not served by micro
about: If you have a need not served by go-micro
title: "[FEATURE]"
labels: ''
assignees: ''
@ -14,4 +14,4 @@ A clear and concise description of what the problem is. Ex. I'm always frustrate
A clear and concise description of what you want to happen.
**Additional context**
Add any other context or screenshots about the feature request here.
Add any other context or screenshots about the feature request here.

14
.github/ISSUE_TEMPLATE/question.md vendored Normal file
View File

@ -0,0 +1,14 @@
---
name: Question
about: Ask a question about go-micro
title: ''
labels: ''
assignees: ''
---
Before asking, please check if your question has already been answered:
1. Check the documentation - https://micro.mu/docs/
2. Check the examples and plugins - https://github.com/micro/examples & https://github.com/micro/go-plugins
3. Search existing issues

19
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,19 @@
# 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 all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
# Maintain dependencies for Golang
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"

20
.github/workflows/autoapprove.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: "autoapprove"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
permissions:
pull-requests: write
contents: write
jobs:
autoapprove:
runs-on: ubuntu-latest
steps:
- name: approve
uses: hmarr/auto-approve-action@v3
if: github.actor == 'vtolstov' || github.actor == 'dependabot[bot]'
id: approve
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

21
.github/workflows/automerge.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: "automerge"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
permissions:
pull-requests: write
contents: write
jobs:
automerge:
runs-on: ubuntu-latest
if: github.actor == 'vtolstov'
steps:
- name: merge
id: merge
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}

47
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,47 @@
name: build
on:
push:
branches:
- master
- v3
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: checkout
uses: actions/checkout@v3
- name: cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: deps
run: go get -v -t -d ./...
- name: test
env:
INTEGRATION_TESTS: yes
run: go test -mod readonly -v ./...
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: lint
uses: golangci/golangci-lint-action@v3.4.0
continue-on-error: true
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.30
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

78
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,78 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "codeql"
on:
workflow_run:
workflows: ["prbuild"]
types:
- completed
push:
branches: [ master, v3 ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master, v3 ]
schedule:
- cron: '34 1 * * 0'
jobs:
analyze:
name: analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: checkout
uses: actions/checkout@v3
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
# Initializes the CodeQL tools for scanning.
- name: init
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: analyze
uses: github/codeql-action/analyze@v2

View File

@ -0,0 +1,27 @@
name: "dependabot-automerge"
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
permissions:
pull-requests: write
contents: write
jobs:
automerge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: metadata
id: metadata
uses: dependabot/fetch-metadata@v1.3.6
with:
github-token: "${{ secrets.TOKEN }}"
- name: merge
id: merge
if: ${{contains(steps.metadata.outputs.dependency-names, 'go.unistack.org')}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.TOKEN}}

47
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,47 @@
name: prbuild
on:
pull_request:
branches:
- master
- v3
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- name: setup
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: checkout
uses: actions/checkout@v3
- name: cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-
- name: deps
run: go get -v -t -d ./...
- name: test
env:
INTEGRATION_TESTS: yes
run: go test -mod readonly -v ./...
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: lint
uses: golangci/golangci-lint-action@v3.4.0
continue-on-error: true
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.30
# Optional: working directory, useful for monorepos
# working-directory: somedir
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

View File

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: api/annotations.proto
# Protobuf Python Version: 4.25.3
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
# @@protoc_insertion_point(imports)
_sym_db = _symbol_database.Default()
from api import http_pb2 as api_dot_http__pb2
from api import micro_pb2 as api_dot_micro__pb2
from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15\x61pi/annotations.proto\x12\tmicro.api\x1a\x0e\x61pi/http.proto\x1a\x0f\x61pi/micro.proto\x1a google/protobuf/descriptor.proto:D\n\x04http\x12\x1e.google.protobuf.MethodOptions\x18\xa6\xfd\x9f\x1f \x01(\x0b\x32\x13.micro.api.HttpRule:O\n\x0cmicro_method\x12\x1e.google.protobuf.MethodOptions\x18\xa7\xfd\x9f\x1f \x01(\x0b\x32\x16.micro.api.MicroMethod:R\n\rmicro_service\x12\x1f.google.protobuf.ServiceOptions\x18\xa7\xfd\x9f\x1f \x01(\x0b\x32\x17.micro.api.MicroServiceBN\n\tmicro.apiB\x10\x41nnotationsProtoP\x01Z&go.unistack.org/micro-proto/v3/api;api\xa2\x02\x04MAPIb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'api.annotations_pb2', _globals)
if _descriptor._USE_C_DESCRIPTORS == False:
_globals['DESCRIPTOR']._options = None
_globals['DESCRIPTOR']._serialized_options = b'\n\tmicro.apiB\020AnnotationsProtoP\001Z&go.unistack.org/micro-proto/v3/api;api\242\002\004MAPI'
# @@protoc_insertion_point(module_scope)

View File

@ -124,8 +124,8 @@ type Oneof struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ignore bool `protobuf:"varint,4,opt,name=ignore,proto3" json:"ignore,omitempty"`
Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"`
Ignore *bool `protobuf:"varint,4,opt,name=ignore,proto3,oneof" json:"ignore,omitempty"`
Name *string `protobuf:"bytes,5,opt,name=name,proto3,oneof" json:"name,omitempty"`
}
func (x *Oneof) Reset() {
@ -161,15 +161,15 @@ func (*Oneof) Descriptor() ([]byte, []int) {
}
func (x *Oneof) GetIgnore() bool {
if x != nil {
return x.Ignore
if x != nil && x.Ignore != nil {
return *x.Ignore
}
return false
}
func (x *Oneof) GetName() string {
if x != nil {
return x.Name
if x != nil && x.Name != nil {
return *x.Name
}
return ""
}
@ -179,11 +179,11 @@ type Field struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Required bool `protobuf:"varint,1,opt,name=required,proto3" json:"required,omitempty"`
Params string `protobuf:"bytes,2,opt,name=params,proto3" json:"params,omitempty"`
Dirs string `protobuf:"bytes,3,opt,name=dirs,proto3" json:"dirs,omitempty"`
Ignore bool `protobuf:"varint,4,opt,name=ignore,proto3" json:"ignore,omitempty"`
Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"`
Required *bool `protobuf:"varint,1,opt,name=required,proto3,oneof" json:"required,omitempty"`
Params *string `protobuf:"bytes,2,opt,name=params,proto3,oneof" json:"params,omitempty"`
Dirs *string `protobuf:"bytes,3,opt,name=dirs,proto3,oneof" json:"dirs,omitempty"`
Ignore *bool `protobuf:"varint,4,opt,name=ignore,proto3,oneof" json:"ignore,omitempty"`
Name *string `protobuf:"bytes,5,opt,name=name,proto3,oneof" json:"name,omitempty"`
}
func (x *Field) Reset() {
@ -219,36 +219,36 @@ func (*Field) Descriptor() ([]byte, []int) {
}
func (x *Field) GetRequired() bool {
if x != nil {
return x.Required
if x != nil && x.Required != nil {
return *x.Required
}
return false
}
func (x *Field) GetParams() string {
if x != nil {
return x.Params
if x != nil && x.Params != nil {
return *x.Params
}
return ""
}
func (x *Field) GetDirs() string {
if x != nil {
return x.Dirs
if x != nil && x.Dirs != nil {
return *x.Dirs
}
return ""
}
func (x *Field) GetIgnore() bool {
if x != nil {
return x.Ignore
if x != nil && x.Ignore != nil {
return *x.Ignore
}
return false
}
func (x *Field) GetName() string {
if x != nil {
return x.Name
if x != nil && x.Name != nil {
return *x.Name
}
return ""
}
@ -258,9 +258,9 @@ type Rpc struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type Type `protobuf:"varint,1,opt,name=type,proto3,enum=micro.graphql.Type" json:"type,omitempty"`
Ignore bool `protobuf:"varint,2,opt,name=ignore,proto3" json:"ignore,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
Type *Type `protobuf:"varint,1,opt,name=type,proto3,enum=micro.graphql.Type,oneof" json:"type,omitempty"`
Ignore *bool `protobuf:"varint,2,opt,name=ignore,proto3,oneof" json:"ignore,omitempty"`
Name *string `protobuf:"bytes,3,opt,name=name,proto3,oneof" json:"name,omitempty"`
}
func (x *Rpc) Reset() {
@ -296,22 +296,22 @@ func (*Rpc) Descriptor() ([]byte, []int) {
}
func (x *Rpc) GetType() Type {
if x != nil {
return x.Type
if x != nil && x.Type != nil {
return *x.Type
}
return Type_DEFAULT
}
func (x *Rpc) GetIgnore() bool {
if x != nil {
return x.Ignore
if x != nil && x.Ignore != nil {
return *x.Ignore
}
return false
}
func (x *Rpc) GetName() string {
if x != nil {
return x.Name
if x != nil && x.Name != nil {
return *x.Name
}
return ""
}
@ -321,10 +321,10 @@ type Svc struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type Type `protobuf:"varint,1,opt,name=type,proto3,enum=micro.graphql.Type" json:"type,omitempty"`
Ignore bool `protobuf:"varint,2,opt,name=ignore,proto3" json:"ignore,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
Upstream Upstream `protobuf:"varint,4,opt,name=upstream,proto3,enum=micro.graphql.Upstream" json:"upstream,omitempty"`
Type *Type `protobuf:"varint,1,opt,name=type,proto3,enum=micro.graphql.Type,oneof" json:"type,omitempty"`
Ignore *bool `protobuf:"varint,2,opt,name=ignore,proto3,oneof" json:"ignore,omitempty"`
Name *string `protobuf:"bytes,3,opt,name=name,proto3,oneof" json:"name,omitempty"`
Upstream *Upstream `protobuf:"varint,4,opt,name=upstream,proto3,enum=micro.graphql.Upstream,oneof" json:"upstream,omitempty"`
}
func (x *Svc) Reset() {
@ -360,29 +360,29 @@ func (*Svc) Descriptor() ([]byte, []int) {
}
func (x *Svc) GetType() Type {
if x != nil {
return x.Type
if x != nil && x.Type != nil {
return *x.Type
}
return Type_DEFAULT
}
func (x *Svc) GetIgnore() bool {
if x != nil {
return x.Ignore
if x != nil && x.Ignore != nil {
return *x.Ignore
}
return false
}
func (x *Svc) GetName() string {
if x != nil {
return x.Name
if x != nil && x.Name != nil {
return *x.Name
}
return ""
}
func (x *Svc) GetUpstream() Upstream {
if x != nil {
return x.Upstream
if x != nil && x.Upstream != nil {
return *x.Upstream
}
return Upstream_UPSTREAM_UNSPECIFIED
}
@ -453,63 +453,77 @@ var file_graphql_graphql_proto_rawDesc = []byte{
0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67,
0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x33, 0x0a, 0x05, 0x4f, 0x6e, 0x65, 0x6f,
0x66, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
0x08, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x7b, 0x0a,
0x05, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72,
0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72,
0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x69,
0x72, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x69, 0x72, 0x73, 0x12, 0x16,
0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06,
0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x5a, 0x0a, 0x03, 0x52, 0x70,
0x63, 0x12, 0x27, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32,
0x13, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e,
0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x67,
0x6e, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f,
0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x8f, 0x01, 0x0a, 0x03, 0x53, 0x76, 0x63, 0x12, 0x27,
0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x6d,
0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x54, 0x79, 0x70,
0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x12,
0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e,
0x61, 0x6d, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18,
0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72,
0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x55, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x08,
0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x2a, 0x2c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65,
0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x0c, 0x0a,
0x08, 0x4d, 0x55, 0x54, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x51,
0x55, 0x45, 0x52, 0x59, 0x10, 0x02, 0x2a, 0x4e, 0x0a, 0x08, 0x55, 0x70, 0x73, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x50, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4d, 0x5f, 0x55,
0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f,
0x55, 0x50, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4d, 0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x10,
0x01, 0x12, 0x13, 0x0a, 0x0f, 0x55, 0x50, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4d, 0x5f, 0x43, 0x4c,
0x49, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x3a, 0x46, 0x0a, 0x03, 0x72, 0x70, 0x63, 0x12, 0x1e, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x86, 0xfc,
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72,
0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x52, 0x70, 0x63, 0x52, 0x03, 0x72, 0x70, 0x63, 0x3a, 0x47,
0x0a, 0x03, 0x73, 0x76, 0x63, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f,
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x86, 0xfc, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12,
0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x53,
0x76, 0x63, 0x52, 0x03, 0x73, 0x76, 0x63, 0x3a, 0x4b, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64,
0x12, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18,
0x86, 0xfc, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e,
0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x05, 0x66,
0x69, 0x65, 0x6c, 0x64, 0x3a, 0x4b, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x12, 0x1d, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x86, 0xfc, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72, 0x61,
0x70, 0x68, 0x71, 0x6c, 0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x52, 0x05, 0x6f, 0x6e, 0x65, 0x6f,
0x66, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b,
0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2f, 0x76, 0x33, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x3b, 0x67, 0x72, 0x61, 0x70,
0x68, 0x71, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x05, 0x4f, 0x6e, 0x65, 0x6f,
0x66, 0x12, 0x1b, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
0x08, 0x48, 0x00, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17,
0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x69, 0x67, 0x6e, 0x6f,
0x72, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc9, 0x01, 0x0a, 0x05,
0x46, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1f, 0x0a, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x08, 0x72, 0x65, 0x71, 0x75, 0x69,
0x72, 0x65, 0x64, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x64, 0x69, 0x72, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x48, 0x02, 0x52, 0x04, 0x64, 0x69, 0x72, 0x73, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06,
0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x48, 0x03, 0x52, 0x06,
0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x48, 0x04, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x88,
0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x42,
0x09, 0x0a, 0x07, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x64,
0x69, 0x72, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x42, 0x07,
0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x86, 0x01, 0x0a, 0x03, 0x52, 0x70, 0x63, 0x12,
0x2c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e,
0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x54, 0x79,
0x70, 0x65, 0x48, 0x00, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a,
0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x01, 0x52,
0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x09, 0x0a, 0x07,
0x5f, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, 0x6d, 0x65,
0x22, 0xcd, 0x01, 0x0a, 0x03, 0x53, 0x76, 0x63, 0x12, 0x2c, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67,
0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x04, 0x74,
0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1b, 0x0a, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x01, 0x52, 0x06, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65,
0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x48, 0x02, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x38, 0x0a, 0x08,
0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17,
0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x55,
0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x48, 0x03, 0x52, 0x08, 0x75, 0x70, 0x73, 0x74, 0x72,
0x65, 0x61, 0x6d, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42,
0x09, 0x0a, 0x07, 0x5f, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e,
0x61, 0x6d, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x75, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x2a, 0x2c, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x46, 0x41,
0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x4d, 0x55, 0x54, 0x41, 0x54, 0x49, 0x4f,
0x4e, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x51, 0x55, 0x45, 0x52, 0x59, 0x10, 0x02, 0x2a, 0x4e,
0x0a, 0x08, 0x55, 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x50,
0x53, 0x54, 0x52, 0x45, 0x41, 0x4d, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49,
0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x55, 0x50, 0x53, 0x54, 0x52, 0x45, 0x41, 0x4d,
0x5f, 0x53, 0x45, 0x52, 0x56, 0x45, 0x52, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x55, 0x50, 0x53,
0x54, 0x52, 0x45, 0x41, 0x4d, 0x5f, 0x43, 0x4c, 0x49, 0x45, 0x4e, 0x54, 0x10, 0x02, 0x3a, 0x49,
0x0a, 0x03, 0x72, 0x70, 0x63, 0x12, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x4f, 0x70,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x86, 0xfc, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e,
0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x52, 0x70,
0x63, 0x52, 0x03, 0x72, 0x70, 0x63, 0x88, 0x01, 0x01, 0x3a, 0x4a, 0x0a, 0x03, 0x73, 0x76, 0x63,
0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x18, 0x86, 0xfc, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, 0x69, 0x63, 0x72,
0x6f, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x53, 0x76, 0x63, 0x52, 0x03, 0x73,
0x76, 0x63, 0x88, 0x01, 0x01, 0x3a, 0x4e, 0x0a, 0x05, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x12, 0x1d,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x86, 0xfc,
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72,
0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x52, 0x05, 0x66, 0x69, 0x65,
0x6c, 0x64, 0x88, 0x01, 0x01, 0x3a, 0x4e, 0x0a, 0x05, 0x6f, 0x6e, 0x65, 0x6f, 0x66, 0x12, 0x1d,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x86, 0xfc,
0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x67, 0x72,
0x61, 0x70, 0x68, 0x71, 0x6c, 0x2e, 0x4f, 0x6e, 0x65, 0x6f, 0x66, 0x52, 0x05, 0x6f, 0x6e, 0x65,
0x6f, 0x66, 0x88, 0x01, 0x01, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x6f, 0x2e, 0x75, 0x6e, 0x69, 0x73,
0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x33, 0x2f, 0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x3b,
0x67, 0x72, 0x61, 0x70, 0x68, 0x71, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -612,6 +626,10 @@ func file_graphql_graphql_proto_init() {
}
}
}
file_graphql_graphql_proto_msgTypes[0].OneofWrappers = []interface{}{}
file_graphql_graphql_proto_msgTypes[1].OneofWrappers = []interface{}{}
file_graphql_graphql_proto_msgTypes[2].OneofWrappers = []interface{}{}
file_graphql_graphql_proto_msgTypes[3].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@ -9,45 +9,45 @@ import "google/protobuf/descriptor.proto";
// TODO: Email protobuf-global-extension-registry@google.com to get an extension ID.
extend google.protobuf.MethodOptions {
Rpc rpc = 65030;
optional Rpc rpc = 65030;
}
extend google.protobuf.ServiceOptions {
Svc svc = 65030;
optional Svc svc = 65030;
}
extend google.protobuf.FieldOptions {
Field field = 65030;
optional Field field = 65030;
}
extend google.protobuf.OneofOptions {
Oneof oneof = 65030;
optional Oneof oneof = 65030;
}
message Oneof {
bool ignore = 4;
string name = 5;
optional bool ignore = 4;
optional string name = 5;
}
message Field {
bool required = 1;
string params = 2;
string dirs = 3;
bool ignore = 4;
string name = 5;
optional bool required = 1;
optional string params = 2;
optional string dirs = 3;
optional bool ignore = 4;
optional string name = 5;
}
message Rpc {
Type type = 1;
bool ignore = 2;
string name = 3;
optional Type type = 1;
optional bool ignore = 2;
optional string name = 3;
}
message Svc {
Type type = 1;
bool ignore = 2;
string name = 3;
Upstream upstream = 4;
optional Type type = 1;
optional bool ignore = 2;
optional string name = 3;
optional Upstream upstream = 4;
}
enum Type {

View File

@ -1,171 +0,0 @@
package graphql
import (
"context"
"encoding/json"
"fmt"
"io"
"strconv"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
)
type DummyResolver struct{}
func (r *DummyResolver) Dummy(ctx context.Context) (*bool, error) { return nil, nil }
func MarshalBytes(b []byte) ContextMarshaler {
return WriterFunc(func(w io.Writer) {
_, _ = fmt.Fprintf(w, "%q", string(b))
})
}
func UnmarshalBytes(v interface{}) ([]byte, error) {
switch v := v.(type) {
case string:
return []byte(v), nil
case *string:
return []byte(*v), nil
case []byte:
return v, nil
case json.RawMessage:
return []byte(v), nil
default:
return nil, fmt.Errorf("%T is not []byte", v)
}
}
func MarshalAny(any any.Any) ContextMarshaler {
return WriterFunc(func(w io.Writer) {
d := &ptypes.DynamicAny{}
if err := ptypes.UnmarshalAny(&any, d); err != nil {
panic("unable to unmarshal any: " + err.Error())
}
if err := json.NewEncoder(w).Encode(d.Message); err != nil {
panic("unable to encode json: " + err.Error())
}
})
}
func UnmarshalAny(v interface{}) (any.Any, error) {
switch v := v.(type) {
case []byte:
return any.Any{}, nil // TODO add an unmarshal mechanism
case json.RawMessage:
return any.Any{}, nil
default:
return any.Any{}, fmt.Errorf("%T is not json.RawMessage", v)
}
}
func MarshalInt32(any int32) ContextMarshaler {
return WriterFunc(func(w io.Writer) {
_, _ = w.Write([]byte(strconv.Itoa(int(any))))
})
}
func UnmarshalInt32(v interface{}) (int32, error) {
switch v := v.(type) {
case int:
return int32(v), nil
case int32:
return v, nil
case json.Number:
i, err := v.Int64()
return int32(i), err
default:
return 0, fmt.Errorf("%T is not int32", v)
}
}
func MarshalInt64(any int64) ContextMarshaler {
return WriterFunc(func(w io.Writer) {
_, _ = w.Write([]byte(strconv.Itoa(int(any))))
})
}
func UnmarshalInt64(v interface{}) (int64, error) {
switch v := v.(type) {
case int:
return int64(v), nil
case int64:
return v, nil
case json.Number:
i, err := v.Int64()
return i, err
default:
return 0, fmt.Errorf("%T is not int32", v)
}
}
func MarshalUint32(any uint32) ContextMarshaler {
return WriterFunc(func(w io.Writer) {
_, _ = w.Write([]byte(strconv.Itoa(int(any))))
})
}
func UnmarshalUint32(v interface{}) (uint32, error) {
switch v := v.(type) {
case int:
return uint32(v), nil
case uint32:
return v, nil
case json.Number:
i, err := v.Int64()
return uint32(i), err
default:
return 0, fmt.Errorf("%T is not int32", v)
}
}
func MarshalUint64(any uint64) ContextMarshaler {
return WriterFunc(func(w io.Writer) {
_, _ = w.Write([]byte(strconv.Itoa(int(any))))
})
}
func UnmarshalUint64(v interface{}) (uint64, error) {
switch v := v.(type) {
case int:
return uint64(v), nil
case uint64:
return v, nil // TODO add an unmarshal mechanism
case json.Number:
i, err := v.Int64()
return uint64(i), err
default:
return 0, fmt.Errorf("%T is not uint64", v)
}
}
func MarshalFloat32(any float32) ContextMarshaler {
return WriterFunc(func(w io.Writer) {
_, _ = w.Write([]byte(strconv.Itoa(int(any))))
})
}
func UnmarshalFloat32(v interface{}) (float32, error) {
switch v := v.(type) {
case int:
return float32(v), nil
case float32:
return v, nil
case json.Number:
f, err := v.Float64()
return float32(f), err
default:
return 0, fmt.Errorf("%T is not float32", v)
}
}
type ContextMarshaler interface {
MarshalGQLContext(ctx context.Context, w io.Writer) error
}
type WriterFunc func(ctx context.Context, writer io.Writer) error
func (f WriterFunc) MarshalGQLContext(ctx context.Context, w io.Writer) error {
return f(ctx, w)
}