[#276] Merge repo with frostfs-api-go
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

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2024-10-07 17:20:25 +03:00 committed by pogpp
parent 5361f0eceb
commit 6ce73790ea
337 changed files with 66666 additions and 283 deletions

View file

@ -0,0 +1,43 @@
package message
import (
"fmt"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/grpc"
)
// Message represents raw Protobuf message
// that can be transmitted via several
// transport protocols.
type Message interface {
// Must return gRPC message that can
// be used for gRPC protocol transmission.
ToGRPCMessage() grpc.Message
// Must restore the message from related
// gRPC message.
//
// If gRPC message is not a related one,
// ErrUnexpectedMessageType can be returned
// to indicate this.
FromGRPCMessage(grpc.Message) error
}
// ErrUnexpectedMessageType is an error that
// is used to indicate message mismatch.
type ErrUnexpectedMessageType struct {
exp, act any
}
// NewUnexpectedMessageType initializes an error about message mismatch
// between act and exp.
func NewUnexpectedMessageType(act, exp any) ErrUnexpectedMessageType {
return ErrUnexpectedMessageType{
exp: exp,
act: act,
}
}
func (e ErrUnexpectedMessageType) Error() string {
return fmt.Sprintf("unexpected message type %T: expected %T", e.act, e.exp)
}