// PostClusterMessage is for internal use. It decodes a protobuf message out of
// the body and forwards it to the BroadcastHandler.
PostClusterMessage is for internal use. It decodes a protobuf message out of
the body and forwards it to the BroadcastHandler.
// PostClusterMessage is for internal use . It decodes a protobuf message out of // the body and forwards it to the BroadcastHandler .
func (api *API) ClusterMessage(ctx context.Context, reqBody io.Reader) error {
	span, _ := tracing.StartSpanFromContext(ctx, "API.ClusterMessage")
	defer span.Finish()
	if err := api.validate(apiClusterMessage); err != nil {
		return errors.Wrap(err, "validating api method")
	}
	body, err := ioutil.ReadAll(reqBody)
	if err != nil {
		return errors.Wrap(err, "reading body")
	}
	typ := body[0]
	msg := getMessage(typ)
	err = api.server.serializer.Unmarshal(body[1:], msg)
	if err != nil {
		return errors.Wrap(err, "deserializing cluster message")
	}
	if err := api.server.receiveMessage(msg); err != nil {
		return errors.Wrap(err, "receiving message")
	}
	return nil
}
func ( api * API ) ClusterMessage ( ctx context . Context , reqBody io . Reader ) error { span , _ := tracing . StartSpanFromContext ( ctx , " " ) defer span . Finish ( ) if err := api . validate ( apiClusterMessage ) ; err != nil { return errors . Wrap ( err , " " ) } body , err := ioutil . ReadAll ( reqBody ) if err != nil { return errors . Wrap ( err , " " ) } typ := body [ 0 ] msg := getMessage ( typ ) err = api . server . serializer . Unmarshal ( body [ 1 : ] , msg ) if err != nil { return errors . Wrap ( err , " " ) } if err := api . server . receiveMessage ( msg ) ; err != nil { return errors . Wrap ( err , " " ) } return nil }
PostClusterMessage is for internal use.
PostClusterMessage is for internal use .
// Read entire body. // Forward the error message.