Documentation
¶
Index ¶
- Constants
- type Ack
- type Error
- type FileDelete
- type FileWrite
- type HttpMsg
- type HttpMsgType
- type Message
- func NewAck(id string) *Message
- func NewError(code int, path string, msg string) *Message
- func NewFileDelete(path string) *Message
- func NewFileWrite(path string, etag string, length int64, contents []byte) *Message
- func NewHttpMsg(from string, syftURL utils.SyftBoxURL, method string, body []byte, ...) *Message
- func NewNack(id string, err string) *Message
- func NewSystemMessage(version string, msg string) *Message
- type MessageType
- type Nack
- type SyftMethod
- type SyftRPCMessage
- type SyftStatus
- type System
- type ValidationError
Constants ¶
const ( // DefaultMessageExpiry is the default time in seconds before a message expires // 1 day DefaultMessageExpiry = 24 * 60 * 60 * time.Second // HTTP Methods MethodGET SyftMethod = "GET" MethodPOST SyftMethod = "POST" MethodPUT SyftMethod = "PUT" MethodDELETE SyftMethod = "DELETE" // Status codes StatusOK SyftStatus = 200 )
const IdSize = 3
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileDelete ¶
type FileDelete struct {
Path string `json:"pth"`
}
type HttpMsgType ¶ added in v0.6.0
type HttpMsgType string
const ( HttpMsgTypeRequest HttpMsgType = "request" HttpMsgTypeResponse HttpMsgType = "response" )
type Message ¶
type Message struct {
Id string `json:"id"`
Type MessageType `json:"typ"`
Data any `json:"dat"`
}
func NewFileDelete ¶
func NewFileWrite ¶
func NewHttpMsg ¶ added in v0.6.0
func NewSystemMessage ¶
func (*Message) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface for Message
type MessageType ¶
type MessageType uint16
const ( MsgSystem MessageType = iota MsgError MsgFileWrite MsgFileDelete MsgAck MsgNack MsgHttp )
func (MessageType) String ¶
func (t MessageType) String() string
type SyftMethod ¶ added in v0.6.0
type SyftMethod string
SyftMethod represents the HTTP method in the Syft protocol
func (SyftMethod) IsValid ¶ added in v0.6.0
func (m SyftMethod) IsValid() bool
IsValid checks if the method is valid
func (SyftMethod) Validate ¶ added in v0.6.0
func (m SyftMethod) Validate() error
Validate validates the method
type SyftRPCMessage ¶ added in v0.6.0
type SyftRPCMessage struct {
// ID is the unique identifier of the message
ID uuid.UUID `json:"id"`
// Sender is the sender of the message
Sender string `json:"sender"`
// URL is the URL of the message
URL utils.SyftBoxURL `json:"url"`
// Body is the body of the message in bytes
Body []byte `json:"body,omitempty"`
// Headers contains additional headers for the message
Headers map[string]string `json:"headers"`
// Created is the timestamp when the message was created
Created time.Time `json:"created"`
// Expires is the timestamp when the message expires
Expires time.Time `json:"expires"`
Method SyftMethod `json:"method,omitempty"`
StatusCode SyftStatus `json:"status_code,omitempty"`
}
SyftMessage represents a base message for Syft protocol communication
func NewSyftRPCMessage ¶ added in v0.6.0
func NewSyftRPCMessage( sender string, url utils.SyftBoxURL, method SyftMethod, body []byte, headers map[string]string, ) (*SyftRPCMessage, error)
NewSyftMessage creates a new SyftMessage with default values
func (*SyftRPCMessage) MarshalJSON ¶ added in v0.6.0
func (m *SyftRPCMessage) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling to handle bytes as base64
func (*SyftRPCMessage) ToJsonMap ¶ added in v0.6.0
func (m *SyftRPCMessage) ToJsonMap() map[string]interface{}
JSONString returns a properly formatted JSON string with decoded body
func (*SyftRPCMessage) UnmarshalJSON ¶ added in v0.6.0
func (m *SyftRPCMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling to handle base64 encoded body
func (*SyftRPCMessage) Validate ¶ added in v0.6.0
func (m *SyftRPCMessage) Validate() error
Validate validates the message
type SyftStatus ¶ added in v0.6.0
type SyftStatus int
SyftStatus represents the status code in the Syft protocol
func (SyftStatus) IsValid ¶ added in v0.6.0
func (s SyftStatus) IsValid() bool
IsValid checks if the status code is valid
func (SyftStatus) Validate ¶ added in v0.6.0
func (s SyftStatus) Validate() error
Validate validates the status code
type ValidationError ¶ added in v0.6.0
ValidationError represents a validation error
func (*ValidationError) Error ¶ added in v0.6.0
func (e *ValidationError) Error() string