mirror of
https://github.com/psviderski/uncloud.git
synced 2026-11-10 12:44:16 +00:00
refactor(grpc-proxy): use Metadata.Err() method to get upstream error for a broadcasted request
This commit is contained in:
@@ -4,8 +4,16 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"net/netip"
|
||||
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Err returns the upstream error, preserving its gRPC status code.
|
||||
// It returns nil for nil metadata or an absent or successful status.
|
||||
func (m *Metadata) Err() error {
|
||||
return status.ErrorProto(m.GetStatus())
|
||||
}
|
||||
|
||||
func NewIP(addr netip.Addr) *IP {
|
||||
// MarshalBinary always returns a nil error.
|
||||
ip, _ := addr.MarshalBinary()
|
||||
|
||||
Reference in New Issue
Block a user