parent
03ccd0131a
commit
0411a5045b
@ -0,0 +1,28 @@
|
|||||||
|
package a2r
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Call TEST
|
||||||
|
func Call[A, B, C, D, E any](
|
||||||
|
apiReq *A,
|
||||||
|
apiResp *B,
|
||||||
|
rpc func(client E, ctx context.Context, req C, options ...grpc.CallOption) (D, error),
|
||||||
|
client func() (E, error),
|
||||||
|
c *gin.Context,
|
||||||
|
before func(apiReq *A, rpcReq *C, bind func() error) error,
|
||||||
|
after func(rpcResp *D, apiResp *B, bind func() error) error,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Call1[C, D, E any](
|
||||||
|
rpc func(client E, ctx context.Context, req C, options ...grpc.CallOption) (D, error),
|
||||||
|
client func() (E, error),
|
||||||
|
c *gin.Context,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package api2rpc
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FUNC[E, C, D any] func(client E, ctx context.Context, req *C, options ...grpc.CallOption) (*D, error)
|
||||||
|
|
||||||
|
// Call1 TEST
|
||||||
|
func Call1[A, B, C, D, E any](
|
||||||
|
apiReq *A,
|
||||||
|
apiResp *B,
|
||||||
|
rpc FUNC[E, C, D],
|
||||||
|
//client func() (E, error),
|
||||||
|
c *gin.Context,
|
||||||
|
before func(apiReq *A, rpcReq *C, bind func() error) error,
|
||||||
|
after func(rpcResp *D, apiResp *B, bind func() error) error,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Call2[C, D, E any](
|
||||||
|
rpc func(client E, ctx context.Context, req *C, options ...grpc.CallOption) (*D, error),
|
||||||
|
client func() (E, error),
|
||||||
|
c *gin.Context,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Call3[C, D, E any](
|
||||||
|
rpc func(client E, ctx context.Context, req *C, options ...grpc.CallOption) (*D, error),
|
||||||
|
//client func() (E, error),
|
||||||
|
c *gin.Context,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Call4[C, D, E any](
|
||||||
|
rpc func(client E, ctx context.Context, req *C, options ...grpc.CallOption) (*D, error),
|
||||||
|
c *gin.Context,
|
||||||
|
) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Call10[A, B, C, D, E any](apiReq A, apiResp B, client func() (E, error), call func(client E, rpcReq C) (D, error)) {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue