diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f032701..07096c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 with: fetch-depth: 0 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e6cb36c..855009a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - uses: jdx/mise-action@v3 diff --git a/Makefile b/Makefile index af03302..c1cded4 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ install.debug: @echo "〉installing gotsrpc (debug)" @go install -gcflags "all=-N -l" cmd/gotsrpc/gotsrpc.go -EXAMPLES=basic context monitor nullable union time types +EXAMPLES=basic monitor define examples .PHONY: example.$(1) example.$(1): diff --git a/example/basic/client/src/service-client.ts b/example/basic/client/src/service-client.ts index 89b8881..e0754eb 100644 --- a/example/basic/client/src/service-client.ts +++ b/example/basic/client/src/service-client.ts @@ -1,5 +1,5 @@ /* eslint:disable */ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. import * as github_com_foomo_gotsrpc_v2_example_basic_service from './service-vo'; // ./client/src/service-client.ts to ./client/src/service-vo.ts export class ServiceClient { diff --git a/example/basic/client/src/service-vo.ts b/example/basic/client/src/service-vo.ts index 260a987..fe29f40 100644 --- a/example/basic/client/src/service-vo.ts +++ b/example/basic/client/src/service-vo.ts @@ -1,5 +1,5 @@ /* eslint:disable */ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. import * as github_com_foomo_gotsrpc_v2_example_basic_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts // github.com/foomo/gotsrpc/v2/example/basic/service.Float32Type @@ -12,8 +12,6 @@ export enum Float32TypeMapKey { Float32ATypeMapKey = 1, Float32BTypeMapKey = 2, } -// github.com/foomo/gotsrpc/v2/example/basic/service.Float32TypeMapTyped -export type Float32TypeMapTyped = Record // github.com/foomo/gotsrpc/v2/example/basic/service.Float32TypeMapValue export enum Float32TypeMapValue { Float32ATypeMapValue = 1, @@ -29,8 +27,6 @@ export enum Float64TypeMapKey { Float64ATypeMapKey = 1, Float64BTypeMapKey = 2, } -// github.com/foomo/gotsrpc/v2/example/basic/service.Float64TypeMapTyped -export type Float64TypeMapTyped = Record // github.com/foomo/gotsrpc/v2/example/basic/service.Float64TypeMapValue export enum Float64TypeMapValue { Float64ATypeMapValue = 1, @@ -46,8 +42,6 @@ export enum Int32TypeMapKey { Int32ATypeMapKey = 1, Int32BTypeMapKey = 2, } -// github.com/foomo/gotsrpc/v2/example/basic/service.Int32TypeMapTyped -export type Int32TypeMapTyped = Record // github.com/foomo/gotsrpc/v2/example/basic/service.Int32TypeMapValue export enum Int32TypeMapValue { Int32ATypeMapValue = 1, @@ -63,8 +57,6 @@ export enum Int64TypeMapKey { Int64ATypeMapKey = 1, Int64BTypeMapKey = 2, } -// github.com/foomo/gotsrpc/v2/example/basic/service.Int64TypeMapTyped -export type Int64TypeMapTyped = Record // github.com/foomo/gotsrpc/v2/example/basic/service.Int64TypeMapValue export enum Int64TypeMapValue { Int64ATypeMapValue = 1, @@ -80,22 +72,11 @@ export enum IntTypeMapKey { IntATypeMapKey = 1, IntBTypeMapKey = 2, } -// github.com/foomo/gotsrpc/v2/example/basic/service.IntTypeMapTyped -export type IntTypeMapTyped = Record // github.com/foomo/gotsrpc/v2/example/basic/service.IntTypeMapValue export enum IntTypeMapValue { IntATypeMapValue = 1, IntBTypeMapValue = 2, } -// github.com/foomo/gotsrpc/v2/example/basic/service.NestedType -export type NestedType = Record|null>|null> -// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeKey -export type NestedTypeKey = string -// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeSubKey -export type NestedTypeSubKey = string -// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeSubType -export interface NestedTypeSubType { -} // github.com/foomo/gotsrpc/v2/example/basic/service.StringType export enum StringType { StringAType = "A", @@ -106,13 +87,77 @@ export enum StringTypeMapKey { StringATypeMapKey = "A", StringBTypeMapKey = "B", } -// github.com/foomo/gotsrpc/v2/example/basic/service.StringTypeMapTyped -export type StringTypeMapTyped = Record // github.com/foomo/gotsrpc/v2/example/basic/service.StringTypeMapValue export enum StringTypeMapValue { StringATypeMapValue = "A", StringBTypeMapValue = "B", } +// github.com/foomo/gotsrpc/v2/example/basic/service.UInt32Type +export enum UInt32Type { + UInt32AType = 1, + UInt32BType = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UInt32TypeMapKey +export enum UInt32TypeMapKey { + UInt32ATypeMapKey = 1, + UInt32BTypeMapKey = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UInt32TypeMapValue +export enum UInt32TypeMapValue { + UInt32ATypeMapValue = 1, + UInt32BTypeMapValue = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UInt64Type +export enum UInt64Type { + UInt64AType = 1, + UInt64BType = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UInt64TypeMapKey +export enum UInt64TypeMapKey { + UInt64ATypeMapKey = 1, + UInt64BTypeMapKey = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UInt64TypeMapValue +export enum UInt64TypeMapValue { + UInt64ATypeMapValue = 1, + UInt64BTypeMapValue = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UIntType +export enum UIntType { + UIntAType = 1, + UIntBType = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UIntTypeMapKey +export enum UIntTypeMapKey { + UIntATypeMapKey = 1, + UIntBTypeMapKey = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.UIntTypeMapValue +export enum UIntTypeMapValue { + UIntATypeMapValue = 1, + UIntBTypeMapValue = 2, +} +// github.com/foomo/gotsrpc/v2/example/basic/service.Float32TypeMapTyped +export type Float32TypeMapTyped = Record +// github.com/foomo/gotsrpc/v2/example/basic/service.Float64TypeMapTyped +export type Float64TypeMapTyped = Record +// github.com/foomo/gotsrpc/v2/example/basic/service.Int32TypeMapTyped +export type Int32TypeMapTyped = Record +// github.com/foomo/gotsrpc/v2/example/basic/service.Int64TypeMapTyped +export type Int64TypeMapTyped = Record +// github.com/foomo/gotsrpc/v2/example/basic/service.IntTypeMapTyped +export type IntTypeMapTyped = Record +// github.com/foomo/gotsrpc/v2/example/basic/service.NestedType +export type NestedType = Record|null>|null> +// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeKey +export type NestedTypeKey = string +// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeSubKey +export type NestedTypeSubKey = string +// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeSubType +export interface NestedTypeSubType { +} +// github.com/foomo/gotsrpc/v2/example/basic/service.StringTypeMapTyped +export type StringTypeMapTyped = Record // github.com/foomo/gotsrpc/v2/example/basic/service.Struct export interface Struct { Int:number; @@ -135,55 +180,10 @@ export interface Struct { Float64TypeMapTyped:Record|null; StringTypeMapTyped:Record|null; } -// github.com/foomo/gotsrpc/v2/example/basic/service.UInt32Type -export enum UInt32Type { - UInt32AType = 1, - UInt32BType = 2, -} -// github.com/foomo/gotsrpc/v2/example/basic/service.UInt32TypeMapKey -export enum UInt32TypeMapKey { - UInt32ATypeMapKey = 1, - UInt32BTypeMapKey = 2, -} // github.com/foomo/gotsrpc/v2/example/basic/service.UInt32TypeMapTyped export type UInt32TypeMapTyped = Record -// github.com/foomo/gotsrpc/v2/example/basic/service.UInt32TypeMapValue -export enum UInt32TypeMapValue { - UInt32ATypeMapValue = 1, - UInt32BTypeMapValue = 2, -} -// github.com/foomo/gotsrpc/v2/example/basic/service.UInt64Type -export enum UInt64Type { - UInt64AType = 1, - UInt64BType = 2, -} -// github.com/foomo/gotsrpc/v2/example/basic/service.UInt64TypeMapKey -export enum UInt64TypeMapKey { - UInt64ATypeMapKey = 1, - UInt64BTypeMapKey = 2, -} // github.com/foomo/gotsrpc/v2/example/basic/service.UInt64TypeMapTyped export type UInt64TypeMapTyped = Record -// github.com/foomo/gotsrpc/v2/example/basic/service.UInt64TypeMapValue -export enum UInt64TypeMapValue { - UInt64ATypeMapValue = 1, - UInt64BTypeMapValue = 2, -} -// github.com/foomo/gotsrpc/v2/example/basic/service.UIntType -export enum UIntType { - UIntAType = 1, - UIntBType = 2, -} -// github.com/foomo/gotsrpc/v2/example/basic/service.UIntTypeMapKey -export enum UIntTypeMapKey { - UIntATypeMapKey = 1, - UIntBTypeMapKey = 2, -} // github.com/foomo/gotsrpc/v2/example/basic/service.UIntTypeMapTyped export type UIntTypeMapTyped = Record -// github.com/foomo/gotsrpc/v2/example/basic/service.UIntTypeMapValue -export enum UIntTypeMapValue { - UIntATypeMapValue = 1, - UIntBTypeMapValue = 2, -} // end of common js \ No newline at end of file diff --git a/example/basic/service/gorpc_gen.go b/example/basic/service/gorpc_gen.go index ae0d983..3c7397a 100644 --- a/example/basic/service/gorpc_gen.go +++ b/example/basic/service/gorpc_gen.go @@ -1,4 +1,4 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service diff --git a/example/basic/service/gorpcclient_gen.go b/example/basic/service/gorpcclient_gen.go index 9872c7b..750e31e 100644 --- a/example/basic/service/gorpcclient_gen.go +++ b/example/basic/service/gorpcclient_gen.go @@ -1,4 +1,4 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service diff --git a/example/basic/service/gotsrpc_gen.go b/example/basic/service/gotsrpc_gen.go index 5bf0a5b..5ba3c79 100644 --- a/example/basic/service/gotsrpc_gen.go +++ b/example/basic/service/gotsrpc_gen.go @@ -1,10 +1,11 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service import ( io "io" http "net/http" + "reflect" time "time" gotsrpc "github.com/foomo/gotsrpc/v2" @@ -123,6 +124,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() boolRet := p.service.Bool(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Bool) callStats.Execution = time.Since(executionStart) rets = []any{boolRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -146,6 +148,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() boolPtrRet := p.service.BoolPtr(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.BoolPtr) callStats.Execution = time.Since(executionStart) rets = []any{boolPtrRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -169,6 +172,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() boolSliceRet := p.service.BoolSlice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.BoolSlice) callStats.Execution = time.Since(executionStart) rets = []any{boolSliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -185,6 +189,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) executionStart := time.Now() rw := gotsrpc.ResponseWriter{ResponseWriter: w} p.service.Context(&rw, r) + callStats.ResponseTypes = reflect.TypeOf(p.service.Context) callStats.Execution = time.Since(executionStart) if rw.Status() == http.StatusOK { rets = []any{} @@ -202,6 +207,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) ) executionStart := time.Now() p.service.Empty() + callStats.ResponseTypes = reflect.TypeOf(p.service.Empty) callStats.Execution = time.Since(executionStart) rets = []any{} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -225,6 +231,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float32Ret := p.service.Float32(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float32) callStats.Execution = time.Since(executionStart) rets = []any{float32Ret} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -248,6 +255,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float32MapRet := p.service.Float32Map(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float32Map) callStats.Execution = time.Since(executionStart) rets = []any{float32MapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -271,6 +279,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float32SliceRet := p.service.Float32Slice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float32Slice) callStats.Execution = time.Since(executionStart) rets = []any{float32SliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -294,6 +303,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float32TypeRet := p.service.Float32Type(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float32Type) callStats.Execution = time.Since(executionStart) rets = []any{float32TypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -317,6 +327,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float32TypeMapRet := p.service.Float32TypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float32TypeMap) callStats.Execution = time.Since(executionStart) rets = []any{float32TypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -340,6 +351,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float32TypeMapTypedRet := p.service.Float32TypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float32TypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{float32TypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -363,6 +375,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float64Ret := p.service.Float64(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float64) callStats.Execution = time.Since(executionStart) rets = []any{float64Ret} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -386,6 +399,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float64MapRet := p.service.Float64Map(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float64Map) callStats.Execution = time.Since(executionStart) rets = []any{float64MapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -409,6 +423,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float64SliceRet := p.service.Float64Slice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float64Slice) callStats.Execution = time.Since(executionStart) rets = []any{float64SliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -432,6 +447,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float64TypeRet := p.service.Float64Type(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float64Type) callStats.Execution = time.Since(executionStart) rets = []any{float64TypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -455,6 +471,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float64TypeMapRet := p.service.Float64TypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float64TypeMap) callStats.Execution = time.Since(executionStart) rets = []any{float64TypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -478,6 +495,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() float64TypeMapTypedRet := p.service.Float64TypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Float64TypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{float64TypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -501,6 +519,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() intRet := p.service.Int(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int) callStats.Execution = time.Since(executionStart) rets = []any{intRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -524,6 +543,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int32Ret := p.service.Int32(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int32) callStats.Execution = time.Since(executionStart) rets = []any{int32Ret} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -547,6 +567,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int32MapRet := p.service.Int32Map(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int32Map) callStats.Execution = time.Since(executionStart) rets = []any{int32MapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -570,6 +591,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int32SliceRet := p.service.Int32Slice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int32Slice) callStats.Execution = time.Since(executionStart) rets = []any{int32SliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -593,6 +615,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int32TypeRet := p.service.Int32Type(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int32Type) callStats.Execution = time.Since(executionStart) rets = []any{int32TypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -616,6 +639,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int32TypeMapRet := p.service.Int32TypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int32TypeMap) callStats.Execution = time.Since(executionStart) rets = []any{int32TypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -639,6 +663,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int32TypeMapTypedRet := p.service.Int32TypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int32TypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{int32TypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -662,6 +687,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int64Ret := p.service.Int64(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int64) callStats.Execution = time.Since(executionStart) rets = []any{int64Ret} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -685,6 +711,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int64MapRet := p.service.Int64Map(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int64Map) callStats.Execution = time.Since(executionStart) rets = []any{int64MapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -708,6 +735,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int64SliceRet := p.service.Int64Slice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int64Slice) callStats.Execution = time.Since(executionStart) rets = []any{int64SliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -731,6 +759,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int64TypeRet := p.service.Int64Type(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int64Type) callStats.Execution = time.Since(executionStart) rets = []any{int64TypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -754,6 +783,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int64TypeMapRet := p.service.Int64TypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int64TypeMap) callStats.Execution = time.Since(executionStart) rets = []any{int64TypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -777,6 +807,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() int64TypeMapTypedRet := p.service.Int64TypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Int64TypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{int64TypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -800,6 +831,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() intMapRet := p.service.IntMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.IntMap) callStats.Execution = time.Since(executionStart) rets = []any{intMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -823,6 +855,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() intSliceRet := p.service.IntSlice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.IntSlice) callStats.Execution = time.Since(executionStart) rets = []any{intSliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -846,6 +879,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() intTypeRet := p.service.IntType(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.IntType) callStats.Execution = time.Since(executionStart) rets = []any{intTypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -869,6 +903,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() intTypeMapRet := p.service.IntTypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.IntTypeMap) callStats.Execution = time.Since(executionStart) rets = []any{intTypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -892,6 +927,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() intTypeMapTypedRet := p.service.IntTypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.IntTypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{intTypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -915,6 +951,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() interfaceRet := p.service.Interface(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Interface) callStats.Execution = time.Since(executionStart) rets = []any{interfaceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -938,6 +975,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() interfaceSliceRet := p.service.InterfaceSlice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.InterfaceSlice) callStats.Execution = time.Since(executionStart) rets = []any{interfaceSliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -961,6 +999,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() nestedTypeRet := p.service.NestedType(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.NestedType) callStats.Execution = time.Since(executionStart) rets = []any{nestedTypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -984,6 +1023,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() stringRet := p.service.String(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.String) callStats.Execution = time.Since(executionStart) rets = []any{stringRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1007,6 +1047,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() stringMapRet := p.service.StringMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.StringMap) callStats.Execution = time.Since(executionStart) rets = []any{stringMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1030,6 +1071,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() stringSliceRet := p.service.StringSlice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.StringSlice) callStats.Execution = time.Since(executionStart) rets = []any{stringSliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1053,6 +1095,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() stringTypeRet := p.service.StringType(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.StringType) callStats.Execution = time.Since(executionStart) rets = []any{stringTypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1076,6 +1119,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() stringTypeMapRet := p.service.StringTypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.StringTypeMap) callStats.Execution = time.Since(executionStart) rets = []any{stringTypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1099,6 +1143,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() stringTypeMapTypedRet := p.service.StringTypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.StringTypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{stringTypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1122,6 +1167,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() structRet := p.service.Struct(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Struct) callStats.Execution = time.Since(executionStart) rets = []any{structRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1145,6 +1191,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uIntRet := p.service.UInt(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt) callStats.Execution = time.Since(executionStart) rets = []any{uIntRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1168,6 +1215,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt32Ret := p.service.UInt32(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt32) callStats.Execution = time.Since(executionStart) rets = []any{uInt32Ret} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1191,6 +1239,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt32MapRet := p.service.UInt32Map(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt32Map) callStats.Execution = time.Since(executionStart) rets = []any{uInt32MapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1214,6 +1263,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt32SliceRet := p.service.UInt32Slice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt32Slice) callStats.Execution = time.Since(executionStart) rets = []any{uInt32SliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1237,6 +1287,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt32TypeRet := p.service.UInt32Type(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt32Type) callStats.Execution = time.Since(executionStart) rets = []any{uInt32TypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1260,6 +1311,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt32TypeMapRet := p.service.UInt32TypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt32TypeMap) callStats.Execution = time.Since(executionStart) rets = []any{uInt32TypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1283,6 +1335,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt32TypeMapTypedRet := p.service.UInt32TypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt32TypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{uInt32TypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1306,6 +1359,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt64Ret := p.service.UInt64(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt64) callStats.Execution = time.Since(executionStart) rets = []any{uInt64Ret} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1329,6 +1383,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt64MapRet := p.service.UInt64Map(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt64Map) callStats.Execution = time.Since(executionStart) rets = []any{uInt64MapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1352,6 +1407,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt64SliceRet := p.service.UInt64Slice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt64Slice) callStats.Execution = time.Since(executionStart) rets = []any{uInt64SliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1375,6 +1431,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt64TypeRet := p.service.UInt64Type(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt64Type) callStats.Execution = time.Since(executionStart) rets = []any{uInt64TypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1398,6 +1455,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt64TypeMapRet := p.service.UInt64TypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt64TypeMap) callStats.Execution = time.Since(executionStart) rets = []any{uInt64TypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1421,6 +1479,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uInt64TypeMapTypedRet := p.service.UInt64TypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UInt64TypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{uInt64TypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1444,6 +1503,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uIntMapRet := p.service.UIntMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UIntMap) callStats.Execution = time.Since(executionStart) rets = []any{uIntMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1467,6 +1527,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uIntSliceRet := p.service.UIntSlice(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UIntSlice) callStats.Execution = time.Since(executionStart) rets = []any{uIntSliceRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1490,6 +1551,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uIntTypeRet := p.service.UIntType(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UIntType) callStats.Execution = time.Since(executionStart) rets = []any{uIntTypeRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1513,6 +1575,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uIntTypeMapRet := p.service.UIntTypeMap(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UIntTypeMap) callStats.Execution = time.Since(executionStart) rets = []any{uIntTypeMapRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { @@ -1536,6 +1599,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() uIntTypeMapTypedRet := p.service.UIntTypeMapTyped(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.UIntTypeMapTyped) callStats.Execution = time.Since(executionStart) rets = []any{uIntTypeMapTypedRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { diff --git a/example/basic/service/gotsrpcclient_gen.go b/example/basic/service/gotsrpcclient_gen.go index 5501243..efcae8f 100644 --- a/example/basic/service/gotsrpcclient_gen.go +++ b/example/basic/service/gotsrpcclient_gen.go @@ -1,4 +1,4 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service diff --git a/example/monitor/client/src/service-client.ts b/example/monitor/client/src/service-client.ts index 395cd10..9f5a6f2 100644 --- a/example/monitor/client/src/service-client.ts +++ b/example/monitor/client/src/service-client.ts @@ -1,5 +1,5 @@ /* eslint:disable */ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. export class ServiceClient { public static defaultEndpoint = "/service"; diff --git a/example/monitor/service/gorpc_gen.go b/example/monitor/service/gorpc_gen.go index 9fb6125..300c1cd 100644 --- a/example/monitor/service/gorpc_gen.go +++ b/example/monitor/service/gorpc_gen.go @@ -1,4 +1,4 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service diff --git a/example/monitor/service/gorpcclient_gen.go b/example/monitor/service/gorpcclient_gen.go index 3f87660..ff06a86 100644 --- a/example/monitor/service/gorpcclient_gen.go +++ b/example/monitor/service/gorpcclient_gen.go @@ -1,4 +1,4 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service diff --git a/example/monitor/service/gotsrpc_gen.go b/example/monitor/service/gotsrpc_gen.go index 6aa7ea9..23f7b93 100644 --- a/example/monitor/service/gotsrpc_gen.go +++ b/example/monitor/service/gotsrpc_gen.go @@ -1,10 +1,11 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service import ( io "io" http "net/http" + "reflect" time "time" gotsrpc "github.com/foomo/gotsrpc/v2" @@ -61,6 +62,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) } executionStart := time.Now() helloRet := p.service.Hello(arg_v) + callStats.ResponseTypes = reflect.TypeOf(p.service.Hello) callStats.Execution = time.Since(executionStart) rets = []any{helloRet} if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { diff --git a/example/monitor/service/gotsrpcclient_gen.go b/example/monitor/service/gotsrpcclient_gen.go index feafc46..92e44fa 100644 --- a/example/monitor/service/gotsrpcclient_gen.go +++ b/example/monitor/service/gotsrpcclient_gen.go @@ -1,4 +1,4 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. package service diff --git a/example/nullable/client/index.html b/example/nullable/client/index.html deleted file mode 100644 index 02d0c88..0000000 --- a/example/nullable/client/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - Nullable - - - -

A service test

- -
open the console!
-
- - \ No newline at end of file diff --git a/example/nullable/client/src/app.ts b/example/nullable/client/src/app.ts deleted file mode 100644 index 3efecd0..0000000 --- a/example/nullable/client/src/app.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {ServiceClient} from "./service-client.js"; -import {Base} from "./service-vo.js"; -import transport from "./transport.js"; - -export const init = () => { - const client = new ServiceClient(transport("/service")) - - client.variantA({} as Base).then(ret => { - console.log("Variant A", ret) - }) -} diff --git a/example/nullable/client/src/service-client.ts b/example/nullable/client/src/service-client.ts deleted file mode 100644 index ae5f65c..0000000 --- a/example/nullable/client/src/service-client.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* eslint:disable */ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. -import * as github_com_foomo_gotsrpc_v2_example_nullable_service from './service-vo'; // ./client/src/service-client.ts to ./client/src/service-vo.ts - -export class ServiceClient { - public static defaultEndpoint = "/service"; - constructor( - public transport:(method: string, data?: any[]) => Promise - ) {} - async variantA(i1:github_com_foomo_gotsrpc_v2_example_nullable_service.Base):Promise { - return (await this.transport<{0:github_com_foomo_gotsrpc_v2_example_nullable_service.Base}>("VariantA", [i1]))[0] - } - async variantB(i1:github_com_foomo_gotsrpc_v2_example_nullable_service.BCustomType):Promise { - return (await this.transport<{0:github_com_foomo_gotsrpc_v2_example_nullable_service.BCustomType}>("VariantB", [i1]))[0] - } - async variantC(i1:github_com_foomo_gotsrpc_v2_example_nullable_service.BCustomTypes|null):Promise { - return (await this.transport<{0:github_com_foomo_gotsrpc_v2_example_nullable_service.BCustomTypes|null}>("VariantC", [i1]))[0] - } - async variantD(i1:github_com_foomo_gotsrpc_v2_example_nullable_service.BCustomTypesMap|null):Promise { - return (await this.transport<{0:github_com_foomo_gotsrpc_v2_example_nullable_service.BCustomTypesMap|null}>("VariantD", [i1]))[0] - } - async variantE(i1:github_com_foomo_gotsrpc_v2_example_nullable_service.Base|null):Promise { - return (await this.transport<{0:github_com_foomo_gotsrpc_v2_example_nullable_service.Base|null}>("VariantE", [i1]))[0] - } - async variantF(i1:Array|null):Promise|null> { - return (await this.transport<{0:Array|null}>("VariantF", [i1]))[0] - } - async variantG(i1:Record|null):Promise|null> { - return (await this.transport<{0:Record|null}>("VariantG", [i1]))[0] - } - async variantH(i1:github_com_foomo_gotsrpc_v2_example_nullable_service.Base, i2:github_com_foomo_gotsrpc_v2_example_nullable_service.Base|null, i3:Array|null, i4:Record|null):Promise<{r1:github_com_foomo_gotsrpc_v2_example_nullable_service.Base; r2:github_com_foomo_gotsrpc_v2_example_nullable_service.Base|null; r3:Array|null; r4:Record|null}> { - const response = await this.transport<{0:github_com_foomo_gotsrpc_v2_example_nullable_service.Base; 1:github_com_foomo_gotsrpc_v2_example_nullable_service.Base|null; 2:Array|null; 3:Record|null}>("VariantH", [i1, i2, i3, i4]) - return {r1 : response[0], r2 : response[1], r3 : response[2], r4 : response[3]}; - } -} \ No newline at end of file diff --git a/example/nullable/client/src/service-vo.ts b/example/nullable/client/src/service-vo.ts deleted file mode 100644 index 70e1b15..0000000 --- a/example/nullable/client/src/service-vo.ts +++ /dev/null @@ -1,55 +0,0 @@ -/* eslint:disable */ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. -import * as github_com_foomo_gotsrpc_v2_example_nullable_service from './service-vo'; // ./client/src/service-vo.ts to ./client/src/service-vo.ts - -// github.com/foomo/gotsrpc/v2/example/nullable/service.ACustomType -export enum ACustomType { - One = "one", - Two = "two", -} -// github.com/foomo/gotsrpc/v2/example/nullable/service.ACustomTypes -export type ACustomTypes = Array -// github.com/foomo/gotsrpc/v2/example/nullable/service.ACustomTypesMap -export type ACustomTypesMap = Record -// github.com/foomo/gotsrpc/v2/example/nullable/service.BCustomType -export type BCustomType = string -// github.com/foomo/gotsrpc/v2/example/nullable/service.BCustomTypes -export type BCustomTypes = Array -// github.com/foomo/gotsrpc/v2/example/nullable/service.BCustomTypesMap -export type BCustomTypesMap = Record -// github.com/foomo/gotsrpc/v2/example/nullable/service.Base -export interface Base { - a1:github_com_foomo_gotsrpc_v2_example_nullable_service.Nested; - a2?:github_com_foomo_gotsrpc_v2_example_nullable_service.Nested; - a3:github_com_foomo_gotsrpc_v2_example_nullable_service.Nested|null; - b1:string; - b2?:string; - b3:string|null; - c1:any; - c2?:any; - c3:any; - d1:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomType; - d2?:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomType; - d3:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomType|null; - e1:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomTypes|null; - e2?:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomTypes; - e3:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomTypes|null; - f1:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomTypesMap|null; - f2?:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomTypesMap; - f3:github_com_foomo_gotsrpc_v2_example_nullable_service.ACustomTypesMap|null; - Two:Array|null; - Two1:Array|null>|null; - Two2:Array|null>|null; - Three:Array|null; - Three1:Array|null; - Four:Record|null; - Five:Record|null; - Six:{ - Foo:string; - }|null; -} -// github.com/foomo/gotsrpc/v2/example/nullable/service.Nested -export interface Nested { - Foo:string; -} -// end of common js \ No newline at end of file diff --git a/example/nullable/client/src/transport.ts b/example/nullable/client/src/transport.ts deleted file mode 100644 index 79683ce..0000000 --- a/example/nullable/client/src/transport.ts +++ /dev/null @@ -1,18 +0,0 @@ -const transport = endpoint => async (method: string, args: any = []) => { - return new Promise(async (resolve, reject) => { - fetch( - `${endpoint}/${encodeURIComponent(method)}`, - { - method: 'POST', - body: JSON.stringify(args), - } - ) - .then((response) => { - return response.json() as Promise; - }) - .then((val) => resolve(val)) - .catch((err) => reject(err)) - }) -}; - -export default transport diff --git a/example/nullable/client/tsconfig.json b/example/nullable/client/tsconfig.json deleted file mode 100644 index 7729245..0000000 --- a/example/nullable/client/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./dist", - "rootDir": "./src", - } -} \ No newline at end of file diff --git a/example/nullable/gotsrpc.yml b/example/nullable/gotsrpc.yml deleted file mode 100644 index 309143c..0000000 --- a/example/nullable/gotsrpc.yml +++ /dev/null @@ -1,18 +0,0 @@ -module: - name: github.com/foomo/gotsrpc/v2 - path: ../../ - -targets: - nullable: - services: - /service: Service - package: github.com/foomo/gotsrpc/v2/example/nullable/service - out: ./client/src/service-client.ts - gorpc: - - Service - tsrpc: - - Service - -mappings: - github.com/foomo/gotsrpc/v2/example/nullable/service: - out: ./client/src/service-vo.ts diff --git a/example/nullable/main.go b/example/nullable/main.go deleted file mode 100644 index 75bbfb6..0000000 --- a/example/nullable/main.go +++ /dev/null @@ -1,34 +0,0 @@ -package main - -import ( - "context" - "net/http" - "os/exec" - "strings" - "time" - - "github.com/foomo/gotsrpc/v2/example/nullable/service" -) - -func main() { - ctx := context.Background() - fs := http.FileServer(http.Dir("./nullable/client")) - ws := service.NewDefaultServiceGoTSRPCProxy(&service.Handler{}) - - mux := http.NewServeMux() - mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - switch { - case strings.HasPrefix(r.URL.Path, "/service/"): - ws.ServeHTTP(w, r) - default: - fs.ServeHTTP(w, r) - } - }) - - go func() { - time.Sleep(time.Second) - _ = exec.CommandContext(ctx, "open", "http://127.0.0.1:3000").Run() - }() - - panic(http.ListenAndServe("localhost:3000", mux)) //nolint:gosec -} diff --git a/example/nullable/service/handler.go b/example/nullable/service/handler.go deleted file mode 100644 index 9cc28ea..0000000 --- a/example/nullable/service/handler.go +++ /dev/null @@ -1,39 +0,0 @@ -package service - -import ( - "net/http" -) - -type Handler struct{} - -func (h *Handler) VariantA(w http.ResponseWriter, r *http.Request, i1 Base) (r1 Base) { - return i1 -} - -func (h *Handler) VariantB(w http.ResponseWriter, r *http.Request, i1 BCustomType) (r1 BCustomType) { - return i1 -} - -func (h *Handler) VariantC(w http.ResponseWriter, r *http.Request, i1 BCustomTypes) (r1 BCustomTypes) { - return i1 -} - -func (h *Handler) VariantD(w http.ResponseWriter, r *http.Request, i1 BCustomTypesMap) (r1 BCustomTypesMap) { - return i1 -} - -func (h *Handler) VariantE(w http.ResponseWriter, r *http.Request, i1 *Base) (r1 *Base) { - return i1 -} - -func (h *Handler) VariantF(w http.ResponseWriter, r *http.Request, i1 []*Base) (r1 []*Base) { - return i1 -} - -func (h *Handler) VariantG(w http.ResponseWriter, r *http.Request, i1 map[string]*Base) (r1 map[string]*Base) { - return i1 -} - -func (h *Handler) VariantH(w http.ResponseWriter, r *http.Request, i1 Base, i2 *Base, i3 []*Base, i4 map[string]Base) (r1 Base, r2 *Base, r3 []*Base, r4 map[string]Base) { - panic("implement me") -} diff --git a/example/nullable/service/service.go b/example/nullable/service/service.go deleted file mode 100644 index afc1886..0000000 --- a/example/nullable/service/service.go +++ /dev/null @@ -1,20 +0,0 @@ -package service - -import ( - "net/http" -) - -type Service interface { - VariantA(w http.ResponseWriter, r *http.Request, i1 Base) (r1 Base) - VariantB(w http.ResponseWriter, r *http.Request, i1 BCustomType) (r1 BCustomType) - VariantC(w http.ResponseWriter, r *http.Request, i1 BCustomTypes) (r1 BCustomTypes) - VariantD(w http.ResponseWriter, r *http.Request, i1 BCustomTypesMap) (r1 BCustomTypesMap) - - VariantE(w http.ResponseWriter, r *http.Request, i1 *Base) (r1 *Base) - - VariantF(w http.ResponseWriter, r *http.Request, i1 []*Base) (r1 []*Base) - - VariantG(w http.ResponseWriter, r *http.Request, i1 map[string]*Base) (r1 map[string]*Base) - - VariantH(w http.ResponseWriter, r *http.Request, i1 Base, i2 *Base, i3 []*Base, i4 map[string]Base) (r1 Base, r2 *Base, r3 []*Base, r4 map[string]Base) -} diff --git a/tests/nullable/client/client.test.ts b/tests/nullable/client/client.test.ts new file mode 100644 index 0000000..887b8c3 --- /dev/null +++ b/tests/nullable/client/client.test.ts @@ -0,0 +1,99 @@ +import { expect, test } from "bun:test"; +import transport from "../../lib/transport"; +import { ServiceClient } from "./client.ts"; +import { ACustomType, type Base } from "./vo.ts"; + +const client = new ServiceClient( + transport(`${process.env.GOTSRPC_SERVER_URL}${ServiceClient.defaultEndpoint}`) +); + +const base: Base = { + a1: { Foo: "nested" }, + a3: null, + b1: "hello", + b3: null, + c1: "anything", + c3: null, + d1: ACustomType.One, + d3: null, + e1: null, + e3: null, + f1: null, + f3: null, + Two: null, + Two1: null, + Two2: null, + Three: null, + Three1: null, + Four: null, + Five: null, + Six: null, +}; + +test("variantA", async () => { + const ret = await client.variantA(base); + expect(ret.b1).toBe("hello"); + expect(ret.a1).toEqual({ Foo: "nested" }); + expect(ret.d1).toBe(ACustomType.One); +}); + +test("variantB", async () => { + expect(await client.variantB("custom")).toBe("custom"); +}); + +test("variantC", async () => { + expect(await client.variantC(["a", "b"])).toEqual(["a", "b"]); +}); + +test("variantC null", async () => { + expect(await client.variantC(null)).toBeNull(); +}); + +test("variantD", async () => { + const v = { x: "y" }; + expect(await client.variantD(v)).toEqual(v); +}); + +test("variantD null", async () => { + expect(await client.variantD(null)).toBeNull(); +}); + +test("variantE", async () => { + const ret = await client.variantE(base); + expect(ret).not.toBeNull(); + expect(ret!.b1).toBe("hello"); +}); + +test("variantE null", async () => { + expect(await client.variantE(null)).toBeNull(); +}); + +test("variantF", async () => { + const v: (Base | null)[] = [base, null]; + const ret = await client.variantF(v); + expect(ret).not.toBeNull(); + expect(ret!.length).toBe(2); + expect(ret![0]!.b1).toBe("hello"); + expect(ret![1]).toBeNull(); +}); + +test("variantG", async () => { + const v = { k: base }; + const ret = await client.variantG(v); + expect(ret).not.toBeNull(); + expect(ret!["k"]!.b1).toBe("hello"); +}); + +test("variantH", async () => { + const i2: Base = { ...base, b1: "two" }; + const i3: (Base | null)[] = [{ ...base, b1: "three" }]; + const i4 = { k: { ...base, b1: "four" } }; + const ret = await client.variantH(base, i2, i3, i4); + expect(ret.r1.b1).toBe("hello"); + expect(ret.r2).not.toBeNull(); + expect(ret.r2!.b1).toBe("two"); + expect(ret.r3).not.toBeNull(); + expect(ret.r3![0]!.b1).toBe("three"); + expect(ret.r4).not.toBeNull(); + expect(ret.r4!["k"]!.b1).toBe("four"); +}); diff --git a/tests/nullable/client/client.ts b/tests/nullable/client/client.ts new file mode 100644 index 0000000..791151d --- /dev/null +++ b/tests/nullable/client/client.ts @@ -0,0 +1,35 @@ +/* eslint:disable */ +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +import * as github_com_foomo_gotsrpc_v2_tests_nullable_server from './vo'; // ./client/client.ts to ./client/vo.ts + +export class ServiceClient { + public static defaultEndpoint = "/service"; + constructor( + public transport:(method: string, data?: any[]) => Promise + ) {} + async variantA(i1:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base):Promise { + return (await this.transport<{0:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base}>("VariantA", [i1]))[0] + } + async variantB(i1:github_com_foomo_gotsrpc_v2_tests_nullable_server.BCustomType):Promise { + return (await this.transport<{0:github_com_foomo_gotsrpc_v2_tests_nullable_server.BCustomType}>("VariantB", [i1]))[0] + } + async variantC(i1:github_com_foomo_gotsrpc_v2_tests_nullable_server.BCustomTypes|null):Promise { + return (await this.transport<{0:github_com_foomo_gotsrpc_v2_tests_nullable_server.BCustomTypes|null}>("VariantC", [i1]))[0] + } + async variantD(i1:github_com_foomo_gotsrpc_v2_tests_nullable_server.BCustomTypesMap|null):Promise { + return (await this.transport<{0:github_com_foomo_gotsrpc_v2_tests_nullable_server.BCustomTypesMap|null}>("VariantD", [i1]))[0] + } + async variantE(i1:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base|null):Promise { + return (await this.transport<{0:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base|null}>("VariantE", [i1]))[0] + } + async variantF(i1:Array|null):Promise|null> { + return (await this.transport<{0:Array|null}>("VariantF", [i1]))[0] + } + async variantG(i1:Record|null):Promise|null> { + return (await this.transport<{0:Record|null}>("VariantG", [i1]))[0] + } + async variantH(i1:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base, i2:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base|null, i3:Array|null, i4:Record|null):Promise<{r1:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base; r2:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base|null; r3:Array|null; r4:Record|null}> { + const response = await this.transport<{0:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base; 1:github_com_foomo_gotsrpc_v2_tests_nullable_server.Base|null; 2:Array|null; 3:Record|null}>("VariantH", [i1, i2, i3, i4]) + return {r1 : response[0], r2 : response[1], r3 : response[2], r4 : response[3]}; + } +} \ No newline at end of file diff --git a/tests/nullable/client/vo.ts b/tests/nullable/client/vo.ts new file mode 100644 index 0000000..d2f8dd6 --- /dev/null +++ b/tests/nullable/client/vo.ts @@ -0,0 +1,55 @@ +/* eslint:disable */ +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +import * as github_com_foomo_gotsrpc_v2_tests_nullable_server from './vo'; // ./client/vo.ts to ./client/vo.ts + +// github.com/foomo/gotsrpc/v2/tests/nullable/server.ACustomType +export enum ACustomType { + One = "one", + Two = "two", +} +// github.com/foomo/gotsrpc/v2/tests/nullable/server.ACustomTypes +export type ACustomTypes = Array +// github.com/foomo/gotsrpc/v2/tests/nullable/server.ACustomTypesMap +export type ACustomTypesMap = Record +// github.com/foomo/gotsrpc/v2/tests/nullable/server.BCustomType +export type BCustomType = string +// github.com/foomo/gotsrpc/v2/tests/nullable/server.BCustomTypes +export type BCustomTypes = Array +// github.com/foomo/gotsrpc/v2/tests/nullable/server.BCustomTypesMap +export type BCustomTypesMap = Record +// github.com/foomo/gotsrpc/v2/tests/nullable/server.Base +export interface Base { + a1:github_com_foomo_gotsrpc_v2_tests_nullable_server.Nested; + a2?:github_com_foomo_gotsrpc_v2_tests_nullable_server.Nested; + a3:github_com_foomo_gotsrpc_v2_tests_nullable_server.Nested|null; + b1:string; + b2?:string; + b3:string|null; + c1:any; + c2?:any; + c3:any; + d1:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomType; + d2?:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomType; + d3:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomType|null; + e1:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomTypes|null; + e2?:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomTypes; + e3:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomTypes|null; + f1:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomTypesMap|null; + f2?:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomTypesMap; + f3:github_com_foomo_gotsrpc_v2_tests_nullable_server.ACustomTypesMap|null; + Two:Array|null; + Two1:Array|null>|null; + Two2:Array|null>|null; + Three:Array|null; + Three1:Array|null; + Four:Record|null; + Five:Record|null; + Six:{ + Foo:string; + }|null; +} +// github.com/foomo/gotsrpc/v2/tests/nullable/server.Nested +export interface Nested { + Foo:string; +} +// end of common js \ No newline at end of file diff --git a/tests/nullable/generate.go b/tests/nullable/generate.go new file mode 100644 index 0000000..34a44cc --- /dev/null +++ b/tests/nullable/generate.go @@ -0,0 +1,3 @@ +package main + +//go:generate go run ../../cmd/gotsrpc/gotsrpc.go gotsrpc.yml diff --git a/tests/nullable/generate_test.go b/tests/nullable/generate_test.go new file mode 100644 index 0000000..b981083 --- /dev/null +++ b/tests/nullable/generate_test.go @@ -0,0 +1,20 @@ +package main_test + +import ( + "net/http/httptest" + "os" + "os/exec" + "testing" + + "github.com/foomo/gotsrpc/v2/tests/nullable/server" + "github.com/stretchr/testify/require" +) + +func TestClient(t *testing.T) { + s := httptest.NewServer(server.NewDefaultServiceGoTSRPCProxy(&server.Handler{})) + cmd := exec.CommandContext(t.Context(), "bun", "test", "./client/client.test.ts") + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Env = append(os.Environ(), "GOTSRPC_SERVER_URL="+s.URL) + require.NoError(t, cmd.Run()) +} diff --git a/tests/nullable/gotsrpc.yml b/tests/nullable/gotsrpc.yml new file mode 100644 index 0000000..2071943 --- /dev/null +++ b/tests/nullable/gotsrpc.yml @@ -0,0 +1,16 @@ +module: + name: github.com/foomo/gotsrpc/v2 + path: ../../ + +targets: + nullable: + services: + /service: Service + package: github.com/foomo/gotsrpc/v2/tests/nullable/server + out: ./client/client.ts + gorpc: [ Service ] + tsrpc: [ Service ] + +mappings: + github.com/foomo/gotsrpc/v2/tests/nullable/server: + out: ./client/vo.ts diff --git a/example/nullable/service/gorpc_gen.go b/tests/nullable/server/gorpc_gen.go similarity index 89% rename from example/nullable/service/gorpc_gen.go rename to tests/nullable/server/gorpc_gen.go index e310d14..5170636 100644 --- a/example/nullable/service/gorpc_gen.go +++ b/tests/nullable/server/gorpc_gen.go @@ -1,6 +1,6 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. -package service +package server import ( tls "crypto/tls" @@ -143,35 +143,35 @@ func (p *ServiceGoRPCProxy) handler(clientAddr string, request any) (response an switch funcName { case "ServiceVariantARequest": req := request.(ServiceVariantARequest) - r1 := p.service.VariantA(nil, nil, req.I1) + r1 := p.service.VariantA(nil, req.I1) response = ServiceVariantAResponse{R1: r1} case "ServiceVariantBRequest": req := request.(ServiceVariantBRequest) - r1 := p.service.VariantB(nil, nil, req.I1) + r1 := p.service.VariantB(nil, req.I1) response = ServiceVariantBResponse{R1: r1} case "ServiceVariantCRequest": req := request.(ServiceVariantCRequest) - r1 := p.service.VariantC(nil, nil, req.I1) + r1 := p.service.VariantC(nil, req.I1) response = ServiceVariantCResponse{R1: r1} case "ServiceVariantDRequest": req := request.(ServiceVariantDRequest) - r1 := p.service.VariantD(nil, nil, req.I1) + r1 := p.service.VariantD(nil, req.I1) response = ServiceVariantDResponse{R1: r1} case "ServiceVariantERequest": req := request.(ServiceVariantERequest) - r1 := p.service.VariantE(nil, nil, req.I1) + r1 := p.service.VariantE(nil, req.I1) response = ServiceVariantEResponse{R1: r1} case "ServiceVariantFRequest": req := request.(ServiceVariantFRequest) - r1 := p.service.VariantF(nil, nil, req.I1) + r1 := p.service.VariantF(nil, req.I1) response = ServiceVariantFResponse{R1: r1} case "ServiceVariantGRequest": req := request.(ServiceVariantGRequest) - r1 := p.service.VariantG(nil, nil, req.I1) + r1 := p.service.VariantG(nil, req.I1) response = ServiceVariantGResponse{R1: r1} case "ServiceVariantHRequest": req := request.(ServiceVariantHRequest) - r1, r2, r3, r4 := p.service.VariantH(nil, nil, req.I1, req.I2, req.I3, req.I4) + r1, r2, r3, r4 := p.service.VariantH(nil, req.I1, req.I2, req.I3, req.I4) response = ServiceVariantHResponse{R1: r1, R2: r2, R3: r3, R4: r4} default: fmt.Println("Unknown request type", reflect.TypeOf(request).String()) @@ -180,7 +180,7 @@ func (p *ServiceGoRPCProxy) handler(clientAddr string, request any) (response an if p.callStatsHandler != nil { p.callStatsHandler(&gotsrpc.CallStats{ Func: funcName, - Package: "github.com/foomo/gotsrpc/v2/example/nullable/service", + Package: "github.com/foomo/gotsrpc/v2/tests/nullable/server", Service: "Service", Execution: time.Since(start), }) diff --git a/example/nullable/service/gorpcclient_gen.go b/tests/nullable/server/gorpcclient_gen.go similarity index 98% rename from example/nullable/service/gorpcclient_gen.go rename to tests/nullable/server/gorpcclient_gen.go index ba1a53a..e46d478 100644 --- a/example/nullable/service/gorpcclient_gen.go +++ b/tests/nullable/server/gorpcclient_gen.go @@ -1,6 +1,6 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. -package service +package server import ( tls "crypto/tls" diff --git a/tests/nullable/server/gorpcclient_test.go b/tests/nullable/server/gorpcclient_test.go new file mode 100644 index 0000000..4ae6f18 --- /dev/null +++ b/tests/nullable/server/gorpcclient_test.go @@ -0,0 +1,68 @@ +package server_test + +import ( + "net" + "testing" + + "github.com/foomo/gotsrpc/v2/tests/nullable/server" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewServiceGoRPCClient(t *testing.T) { + t.Parallel() + + l, err := net.Listen("tcp", "127.0.0.1:0") //nolint:noctx + require.NoError(t, err) + require.NoError(t, l.Close()) + + s := server.NewServiceGoRPCProxy(l.Addr().String(), &server.Handler{}, nil) + require.NoError(t, s.Start()) + t.Cleanup(s.Stop) + + c := server.NewServiceGoRPCClient(l.Addr().String(), nil) + c.Start() + t.Cleanup(c.Stop) + + t.Run("VariantA", func(t *testing.T) { + t.Parallel() + v := server.Base{B1: "hello", D1: server.ACustomTypeOne} + ret, clientErr := c.VariantA(v) + require.NoError(t, clientErr) + assert.Equal(t, v, ret) + }) + + t.Run("VariantB", func(t *testing.T) { + t.Parallel() + v := server.BCustomType("test") + ret, clientErr := c.VariantB(v) + require.NoError(t, clientErr) + assert.Equal(t, v, ret) + }) + + t.Run("VariantE", func(t *testing.T) { + t.Parallel() + v := &server.Base{B1: "ptr"} + ret, clientErr := c.VariantE(v) + require.NoError(t, clientErr) + require.NotNil(t, ret) + assert.Equal(t, v.B1, ret.B1) + }) + + t.Run("VariantH", func(t *testing.T) { + t.Parallel() + i1 := server.Base{B1: "one"} + i2 := &server.Base{B1: "two"} + i3 := []*server.Base{{B1: "three"}} + i4 := map[string]server.Base{"k": {B1: "four"}} + r1, r2, r3, r4, clientErr := c.VariantH(i1, i2, i3, i4) + require.NoError(t, clientErr) + assert.Equal(t, "one", r1.B1) + require.NotNil(t, r2) + assert.Equal(t, "two", r2.B1) + require.Len(t, r3, 1) + assert.Equal(t, "three", r3[0].B1) + require.Contains(t, r4, "k") + assert.Equal(t, "four", r4["k"].B1) + }) +} diff --git a/example/nullable/service/gotsrpc_gen.go b/tests/nullable/server/gotsrpc_gen.go similarity index 66% rename from example/nullable/service/gotsrpc_gen.go rename to tests/nullable/server/gotsrpc_gen.go index eff8468..c158c2d 100644 --- a/example/nullable/service/gotsrpc_gen.go +++ b/tests/nullable/server/gotsrpc_gen.go @@ -1,10 +1,11 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. -package service +package server import ( io "io" http "net/http" + "reflect" time "time" gotsrpc "github.com/foomo/gotsrpc/v2" @@ -50,7 +51,7 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) funcName := gotsrpc.GetCalledFunc(r, p.EndPoint) callStats, _ := gotsrpc.GetStatsForRequest(r) callStats.Func = funcName - callStats.Package = "github.com/foomo/gotsrpc/v2/example/nullable/service" + callStats.Package = "github.com/foomo/gotsrpc/v2/tests/nullable/server" callStats.Service = "Service" switch funcName { case ServiceGoTSRPCProxyVariantA: @@ -67,15 +68,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantAR1 := p.service.VariantA(&rw, r, arg_i1) + variantAR1 := p.service.VariantA(r.Context(), arg_i1) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantA) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantAR1} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantAR1} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return @@ -93,15 +92,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantBR1 := p.service.VariantB(&rw, r, arg_i1) + variantBR1 := p.service.VariantB(r.Context(), arg_i1) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantB) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantBR1} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantBR1} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return @@ -119,15 +116,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantCR1 := p.service.VariantC(&rw, r, arg_i1) + variantCR1 := p.service.VariantC(r.Context(), arg_i1) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantC) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantCR1} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantCR1} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return @@ -145,15 +140,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantDR1 := p.service.VariantD(&rw, r, arg_i1) + variantDR1 := p.service.VariantD(r.Context(), arg_i1) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantD) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantDR1} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantDR1} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return @@ -171,15 +164,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantER1 := p.service.VariantE(&rw, r, arg_i1) + variantER1 := p.service.VariantE(r.Context(), arg_i1) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantE) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantER1} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantER1} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return @@ -197,15 +188,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantFR1 := p.service.VariantF(&rw, r, arg_i1) + variantFR1 := p.service.VariantF(r.Context(), arg_i1) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantF) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantFR1} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantFR1} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return @@ -223,15 +212,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantGR1 := p.service.VariantG(&rw, r, arg_i1) + variantGR1 := p.service.VariantG(r.Context(), arg_i1) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantG) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantGR1} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantGR1} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return @@ -252,15 +239,13 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) return } executionStart := time.Now() - rw := gotsrpc.ResponseWriter{ResponseWriter: w} - variantHR1, variantHR2, variantHR3, variantHR4 := p.service.VariantH(&rw, r, arg_i1, arg_i2, arg_i3, arg_i4) + variantHR1, variantHR2, variantHR3, variantHR4 := p.service.VariantH(r.Context(), arg_i1, arg_i2, arg_i3, arg_i4) + callStats.ResponseTypes = reflect.TypeOf(p.service.VariantH) callStats.Execution = time.Since(executionStart) - if rw.Status() == http.StatusOK { - rets = []any{variantHR1, variantHR2, variantHR3, variantHR4} - if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { - gotsrpc.ErrorCouldNotReply(w) - return - } + rets = []any{variantHR1, variantHR2, variantHR3, variantHR4} + if err := gotsrpc.Reply(rets, callStats, r, w); err != nil { + gotsrpc.ErrorCouldNotReply(w) + return } gotsrpc.Monitor(w, r, args, rets, callStats) return diff --git a/example/nullable/service/gotsrpcclient_gen.go b/tests/nullable/server/gotsrpcclient_gen.go similarity index 93% rename from example/nullable/service/gotsrpcclient_gen.go rename to tests/nullable/server/gotsrpcclient_gen.go index f551a5d..8d6b096 100644 --- a/example/nullable/service/gotsrpcclient_gen.go +++ b/tests/nullable/server/gotsrpcclient_gen.go @@ -1,6 +1,6 @@ -// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. +// Code generated by gotsrpc https://github.com/foomo/gotsrpc/v2 - DO NOT EDIT. -package service +package server import ( go_context "context" @@ -48,7 +48,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantA(ctx go_context.Context, i1 Base) ( rpcReply := []any{&r1} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantA", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantA") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantA") } return } @@ -58,7 +58,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantB(ctx go_context.Context, i1 BCustom rpcReply := []any{&r1} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantB", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantB") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantB") } return } @@ -68,7 +68,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantC(ctx go_context.Context, i1 BCustom rpcReply := []any{&r1} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantC", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantC") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantC") } return } @@ -78,7 +78,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantD(ctx go_context.Context, i1 BCustom rpcReply := []any{&r1} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantD", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantD") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantD") } return } @@ -88,7 +88,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantE(ctx go_context.Context, i1 *Base) rpcReply := []any{&r1} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantE", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantE") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantE") } return } @@ -98,7 +98,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantF(ctx go_context.Context, i1 []*Base rpcReply := []any{&r1} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantF", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantF") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantF") } return } @@ -108,7 +108,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantG(ctx go_context.Context, i1 map[str rpcReply := []any{&r1} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantG", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantG") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantG") } return } @@ -118,7 +118,7 @@ func (tsc *HTTPServiceGoTSRPCClient) VariantH(ctx go_context.Context, i1 Base, i rpcReply := []any{&r1, &r2, &r3, &r4} rpcErr := tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "VariantH", rpcArgs, rpcReply) if rpcErr != nil { - clientErr = pkg_errors.WithMessage(rpcErr, "failed to call service.ServiceGoTSRPCProxy VariantH") + clientErr = pkg_errors.WithMessage(rpcErr, "failed to call server.ServiceGoTSRPCProxy VariantH") } return } diff --git a/tests/nullable/server/gotsrpcclient_test.go b/tests/nullable/server/gotsrpcclient_test.go new file mode 100644 index 0000000..60101f1 --- /dev/null +++ b/tests/nullable/server/gotsrpcclient_test.go @@ -0,0 +1,103 @@ +package server_test + +import ( + "net/http/httptest" + "testing" + + "github.com/foomo/gotsrpc/v2/tests/nullable/server" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewDefaultServiceGoTSRPCClient(t *testing.T) { + t.Parallel() + + s := httptest.NewServer(server.NewDefaultServiceGoTSRPCProxy(&server.Handler{})) + c := server.NewDefaultServiceGoTSRPCClient(s.URL) + t.Cleanup(s.Close) + + t.Run("VariantA", func(t *testing.T) { + t.Parallel() + v := server.Base{B1: "hello", D1: server.ACustomTypeOne} + ret, clientErr := c.VariantA(t.Context(), v) + require.NoError(t, clientErr) + assert.Equal(t, v, ret) + }) + + t.Run("VariantB", func(t *testing.T) { + t.Parallel() + v := server.BCustomType("test") + ret, clientErr := c.VariantB(t.Context(), v) + require.NoError(t, clientErr) + assert.Equal(t, v, ret) + }) + + t.Run("VariantC", func(t *testing.T) { + t.Parallel() + v := server.BCustomTypes{"a", "b"} + ret, clientErr := c.VariantC(t.Context(), v) + require.NoError(t, clientErr) + assert.Equal(t, v, ret) + }) + + t.Run("VariantD", func(t *testing.T) { + t.Parallel() + v := server.BCustomTypesMap{"x": "y"} + ret, clientErr := c.VariantD(t.Context(), v) + require.NoError(t, clientErr) + assert.Equal(t, v, ret) + }) + + t.Run("VariantE", func(t *testing.T) { + t.Parallel() + v := &server.Base{B1: "ptr"} + ret, clientErr := c.VariantE(t.Context(), v) + require.NoError(t, clientErr) + require.NotNil(t, ret) + assert.Equal(t, v.B1, ret.B1) + }) + + t.Run("VariantE_nil", func(t *testing.T) { + t.Parallel() + ret, clientErr := c.VariantE(t.Context(), nil) + require.NoError(t, clientErr) + assert.Nil(t, ret) + }) + + t.Run("VariantF", func(t *testing.T) { + t.Parallel() + v := []*server.Base{{B1: "one"}, {B1: "two"}} + ret, clientErr := c.VariantF(t.Context(), v) + require.NoError(t, clientErr) + require.Len(t, ret, 2) + assert.Equal(t, "one", ret[0].B1) + assert.Equal(t, "two", ret[1].B1) + }) + + t.Run("VariantG", func(t *testing.T) { + t.Parallel() + v := map[string]*server.Base{"k": {B1: "val"}} + ret, clientErr := c.VariantG(t.Context(), v) + require.NoError(t, clientErr) + require.Contains(t, ret, "k") + require.NotNil(t, ret["k"]) + assert.Equal(t, "val", ret["k"].B1) + }) + + t.Run("VariantH", func(t *testing.T) { + t.Parallel() + i1 := server.Base{B1: "one"} + i2 := &server.Base{B1: "two"} + i3 := []*server.Base{{B1: "three"}} + i4 := map[string]server.Base{"k": {B1: "four"}} + r1, r2, r3, r4, clientErr := c.VariantH(t.Context(), i1, i2, i3, i4) + require.NoError(t, clientErr) + assert.Equal(t, "one", r1.B1) + require.NotNil(t, r2) + assert.Equal(t, "two", r2.B1) + require.Len(t, r3, 1) + assert.Equal(t, "three", r3[0].B1) + require.Contains(t, r4, "k") + assert.Equal(t, "four", r4["k"].B1) + }) +} diff --git a/tests/nullable/server/handler.go b/tests/nullable/server/handler.go new file mode 100644 index 0000000..ac134fe --- /dev/null +++ b/tests/nullable/server/handler.go @@ -0,0 +1,20 @@ +package server + +import "context" + +type Handler struct{} + +func (h *Handler) VariantA(_ context.Context, i1 Base) (r1 Base) { return i1 } +func (h *Handler) VariantB(_ context.Context, i1 BCustomType) (r1 BCustomType) { return i1 } +func (h *Handler) VariantC(_ context.Context, i1 BCustomTypes) (r1 BCustomTypes) { return i1 } +func (h *Handler) VariantD(_ context.Context, i1 BCustomTypesMap) (r1 BCustomTypesMap) { return i1 } + +func (h *Handler) VariantE(_ context.Context, i1 *Base) (r1 *Base) { return i1 } + +func (h *Handler) VariantF(_ context.Context, i1 []*Base) (r1 []*Base) { return i1 } + +func (h *Handler) VariantG(_ context.Context, i1 map[string]*Base) (r1 map[string]*Base) { return i1 } + +func (h *Handler) VariantH(_ context.Context, i1 Base, i2 *Base, i3 []*Base, i4 map[string]Base) (r1 Base, r2 *Base, r3 []*Base, r4 map[string]Base) { + return i1, i2, i3, i4 +} diff --git a/tests/nullable/server/handler_test.go b/tests/nullable/server/handler_test.go new file mode 100644 index 0000000..e587f3f --- /dev/null +++ b/tests/nullable/server/handler_test.go @@ -0,0 +1,74 @@ +package server_test + +import ( + "testing" + + "github.com/foomo/gotsrpc/v2/tests/nullable/server" + "github.com/stretchr/testify/assert" +) + +func TestHandler(t *testing.T) { + t.Parallel() + + h := &server.Handler{} + + t.Run("VariantA", func(t *testing.T) { + t.Parallel() + v := server.Base{B1: "hello", D1: server.ACustomTypeOne} + assert.Equal(t, v, h.VariantA(t.Context(), v)) + }) + + t.Run("VariantB", func(t *testing.T) { + t.Parallel() + v := server.BCustomType("test") + assert.Equal(t, v, h.VariantB(t.Context(), v)) + }) + + t.Run("VariantC", func(t *testing.T) { + t.Parallel() + v := server.BCustomTypes{"a", "b"} + assert.Equal(t, v, h.VariantC(t.Context(), v)) + }) + + t.Run("VariantD", func(t *testing.T) { + t.Parallel() + v := server.BCustomTypesMap{"x": "y"} + assert.Equal(t, v, h.VariantD(t.Context(), v)) + }) + + t.Run("VariantE", func(t *testing.T) { + t.Parallel() + v := &server.Base{B1: "ptr"} + assert.Equal(t, v, h.VariantE(t.Context(), v)) + }) + + t.Run("VariantE_nil", func(t *testing.T) { + t.Parallel() + assert.Nil(t, h.VariantE(t.Context(), nil)) + }) + + t.Run("VariantF", func(t *testing.T) { + t.Parallel() + v := []*server.Base{{B1: "one"}, {B1: "two"}} + assert.Equal(t, v, h.VariantF(t.Context(), v)) + }) + + t.Run("VariantG", func(t *testing.T) { + t.Parallel() + v := map[string]*server.Base{"k": {B1: "val"}} + assert.Equal(t, v, h.VariantG(t.Context(), v)) + }) + + t.Run("VariantH", func(t *testing.T) { + t.Parallel() + i1 := server.Base{B1: "one"} + i2 := &server.Base{B1: "two"} + i3 := []*server.Base{{B1: "three"}} + i4 := map[string]server.Base{"k": {B1: "four"}} + r1, r2, r3, r4 := h.VariantH(t.Context(), i1, i2, i3, i4) + assert.Equal(t, i1, r1) + assert.Equal(t, i2, r2) + assert.Equal(t, i3, r3) + assert.Equal(t, i4, r4) + }) +} diff --git a/tests/nullable/server/service.go b/tests/nullable/server/service.go new file mode 100644 index 0000000..fc11feb --- /dev/null +++ b/tests/nullable/server/service.go @@ -0,0 +1,18 @@ +package server + +import "context" + +type Service interface { + VariantA(ctx context.Context, i1 Base) (r1 Base) + VariantB(ctx context.Context, i1 BCustomType) (r1 BCustomType) + VariantC(ctx context.Context, i1 BCustomTypes) (r1 BCustomTypes) + VariantD(ctx context.Context, i1 BCustomTypesMap) (r1 BCustomTypesMap) + + VariantE(ctx context.Context, i1 *Base) (r1 *Base) + + VariantF(ctx context.Context, i1 []*Base) (r1 []*Base) + + VariantG(ctx context.Context, i1 map[string]*Base) (r1 map[string]*Base) + + VariantH(ctx context.Context, i1 Base, i2 *Base, i3 []*Base, i4 map[string]Base) (r1 Base, r2 *Base, r3 []*Base, r4 map[string]Base) +} diff --git a/example/nullable/service/vo.go b/tests/nullable/server/vo.go similarity index 98% rename from example/nullable/service/vo.go rename to tests/nullable/server/vo.go index 6dbdb0b..9bab2f2 100644 --- a/example/nullable/service/vo.go +++ b/tests/nullable/server/vo.go @@ -1,4 +1,4 @@ -package service +package server type ( ACustomType string