frostfs-sdk-go/api/rpc/common/call.go
Pavel Pogodaev 6ce73790ea
All checks were successful
DCO / DCO (pull_request) Successful in 38s
Tests and linters / Tests (pull_request) Successful in 1m13s
Tests and linters / Lint (pull_request) Successful in 2m36s
[#276] Merge repo with frostfs-api-go
Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
2024-10-22 14:05:12 +00:00

75 lines
1.8 KiB
Go

package common
type callType uint8
const (
_ callType = iota
callUnary
callClientStream
callServerStream
callBidirStream
)
// CallMethodInfo is an information about the RPC.
type CallMethodInfo struct {
// Name of the service.
Service string
// Name of the RPC.
Name string
t callType
}
// ServerStream checks if CallMethodInfo contains
// information about the server-side streaming RPC.
func (c CallMethodInfo) ServerStream() bool {
return c.t == callServerStream || c.t == callBidirStream
}
// ClientStream checks if CallMethodInfo contains
// information about the client-side streaming RPC.
func (c CallMethodInfo) ClientStream() bool {
return c.t == callClientStream || c.t == callBidirStream
}
func (c *CallMethodInfo) setCommon(service, name string) {
c.Service = service
c.Name = name
}
// CallMethodInfoUnary returns CallMethodInfo structure
// initialized for the unary RPC.
func CallMethodInfoUnary(service, name string) (info CallMethodInfo) {
info.setCommon(service, name)
info.t = callUnary
return
}
// CallMethodInfoClientStream returns CallMethodInfo structure
// initialized for the client-side streaming RPC.
func CallMethodInfoClientStream(service, name string) (info CallMethodInfo) {
info.setCommon(service, name)
info.t = callClientStream
return
}
// CallMethodInfoServerStream returns CallMethodInfo structure
// initialized for the server-side streaming RPC.
func CallMethodInfoServerStream(service, name string) (info CallMethodInfo) {
info.setCommon(service, name)
info.t = callServerStream
return
}
// CallMethodInfoBidirectionalStream returns CallMethodInfo structure
// initialized for the bidirectional streaming RPC.
func CallMethodInfoBidirectionalStream(service, name string) (info CallMethodInfo) {
info.setCommon(service, name)
info.t = callBidirStream
return
}