types

package
v0.0.0-...-1d800d4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoCapabilities            = Capabilities(0)
	CanEditContent            = CapabilityComponent(2)
	CanSeeOtherClients        = CapabilityComponent(3)
	CanSeeNonRestrictedEvents = CapabilityComponent(5)
	CanSeeAllEditorEvents     = CapabilityComponent(7)
)
View Source
const (
	PublicIdLength         = 22
	PublicIdTsPrefixLength = 11
)
View Source
const (
	JoinDoc           = Action("joinDoc")
	GetConnectedUsers = Action("clientTracking.getConnectedUsers")
	UpdatePosition    = Action("clientTracking.updatePosition")
	ApplyUpdate       = Action("applyUpdate")
	Ping              = Action("ping")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

type BootstrapWSResponse

type BootstrapWSResponse struct {
	// Project contains (cached) serialized types.ProjectDetails
	Project        json.RawMessage            `json:"project"`
	PrivilegeLevel sharedTypes.PrivilegeLevel `json:"privilegeLevel"`
	// ConnectedClients contains (shared) serialized types.ConnectedClients
	ConnectedClients json.RawMessage      `json:"connectedClients"`
	PublicId         sharedTypes.PublicId `json:"publicId"`
}

func (*BootstrapWSResponse) WriteInto

func (b *BootstrapWSResponse) WriteInto(resp *RPCResponse)

type Callback

type Callback int64

type Capabilities

type Capabilities uint8

func (Capabilities) CheckIncludes

func (c Capabilities) CheckIncludes(action CapabilityComponent) error

func (Capabilities) Includes

func (c Capabilities) Includes(action CapabilityComponent) bool

func (Capabilities) TakeAway

func (c Capabilities) TakeAway(action CapabilityComponent) Capabilities

type CapabilityComponent

type CapabilityComponent uint8

type Client

type Client struct {
	HasEmitted bool // only read after disconnect

	PublicId    sharedTypes.PublicId
	ProjectId   sharedTypes.UUID
	UserId      sharedTypes.UUID
	DisplayName string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(conn *websocket.LeanConn, writeQueueDepth int, scheduleWriteQueue chan *Client) *Client

func (*Client) CanDo

func (c *Client) CanDo(action Action, docId sharedTypes.UUID) error

func (*Client) CheckHasCapability

func (c *Client) CheckHasCapability(component CapabilityComponent) error

func (*Client) EnsureQueueMessage

func (c *Client) EnsureQueueMessage(msg WriteQueueEntry) bool

func (*Client) EnsureQueueResponse

func (c *Client) EnsureQueueResponse(response RPCResponse) bool

func (*Client) ForceDisconnect

func (c *Client) ForceDisconnect()

func (*Client) HasCapability

func (c *Client) HasCapability(component CapabilityComponent) bool

func (*Client) HasJoinedDoc

func (c *Client) HasJoinedDoc(id sharedTypes.UUID) bool

func (*Client) MarkAsJoined

func (c *Client) MarkAsJoined(id sharedTypes.UUID)

func (*Client) MarkAsLeftDoc

func (c *Client) MarkAsLeftDoc()

func (*Client) ProcessQueuedMessages

func (c *Client) ProcessQueuedMessages()

func (*Client) ResolveCapabilities

func (c *Client) ResolveCapabilities(privilegeLevel sharedTypes.PrivilegeLevel, isRestrictedUser project.IsRestrictedUser, editable bool)

func (*Client) String

func (c *Client) String() string

func (*Client) TriggerDisconnect

func (c *Client) TriggerDisconnect()

func (*Client) TryWriteResponseOrQueue

func (c *Client) TryWriteResponseOrQueue(response RPCResponse) bool

type ClientPosition

type ClientPosition struct {
	Row      int64            `json:"r,omitempty"`
	Column   int64            `json:"c,omitempty"`
	EntityId sharedTypes.UUID `json:"e"`
}

type Clients

type Clients []*Client

func (Clients) Index

func (c Clients) Index(needle *Client) int

func (Clients) String

func (c Clients) String() string

type ConnectedClient

type ConnectedClient struct {
	ClientId    sharedTypes.PublicId `json:"i,omitempty"`
	DisplayName string               `json:"n,omitempty"`
	ClientPosition
}

type ConnectedClients

type ConnectedClients []ConnectedClient

type ConnectingConnectedClient

type ConnectingConnectedClient struct {
	DisplayName string `json:"n,omitempty"`
}

func (ConnectingConnectedClient) Append

func (c ConnectingConnectedClient) Append(p []byte) []byte

type GetConnectedUsersResponse

type GetConnectedUsersResponse struct {
	// ConnectedClients contains (shared) serialized types.ConnectedClients
	ConnectedClients json.RawMessage `json:"connectedClients"`
}

func (*GetConnectedUsersResponse) MarshalJSON

func (g *GetConnectedUsersResponse) MarshalJSON() ([]byte, error)

type GracefulShutdownOptions

type GracefulShutdownOptions struct {
	Delay          time.Duration `json:"delay"`
	Timeout        time.Duration `json:"timeout"`
	CleanupTimeout time.Duration `json:"cleanup_timeout"`
}

func (*GracefulShutdownOptions) Validate

func (o *GracefulShutdownOptions) Validate() error

type JoinDocRequest

type JoinDocRequest struct {
	FromVersion sharedTypes.Version `json:"fromVersion"`
}

type JoinDocResponse

type JoinDocResponse struct {
	Snapshot sharedTypes.Snapshot         `json:"snapshot"`
	Version  sharedTypes.Version          `json:"version"`
	Updates  []sharedTypes.DocumentUpdate `json:"updates"`
}

type LazySuccessResponse

type LazySuccessResponse struct {
	Callback Callback          `json:"c"`
	Latency  sharedTypes.Timed `json:"l"`
}

type Options

type Options struct {
	GracefulShutdown GracefulShutdownOptions `json:"graceful_shutdown"`

	WriteQueueDepth int `json:"write_queue_depth"`
	BootstrapWorker int `json:"bootstrap_worker"`
	WriteWorker     int `json:"write_worker"`

	JWT struct {
		Project jwtOptions.JWTOptions `json:"project"`
	} `json:"jwt"`
}

func (*Options) FillFromEnv

func (o *Options) FillFromEnv()

func (*Options) Validate

func (o *Options) Validate() error

type ProjectDetails

type ProjectDetails struct {
	project.ForBootstrapWS
	project.OwnerFeaturesField
	project.TokensField                   // stub
	RootFolder          []*project.Folder `json:"rootFolder"`
}

type RPC

type RPC struct {
	Client   *Client
	Request  *RPCRequest
	Response *RPCResponse
}

func (*RPC) Validate

func (r *RPC) Validate() error

type RPCRequest

type RPCRequest struct {
	Action   Action           `json:"a"`
	Body     json.RawMessage  `json:"b"`
	Callback Callback         `json:"c"`
	DocId    sharedTypes.UUID `json:"d"`
}

type RPCResponse

type RPCResponse struct {
	/* "h" is a virtual field indicating the length of Body */
	Body                 json.RawMessage                `json:"b,omitempty"`
	Callback             Callback                       `json:"c,omitempty"`
	Error                *errors.JavaScriptError        `json:"e,omitempty"`
	Name                 sharedTypes.EditorEventMessage `json:"n,omitempty"`
	Latency              sharedTypes.Timed              `json:"l,omitempty"`
	ProcessedBy          string                         `json:"p,omitempty"`
	LazySuccessResponses []LazySuccessResponse          `json:"s,omitempty"`

	FatalError bool `json:"-"`
	// contains filtered or unexported fields
}

func (*RPCResponse) FastUnmarshalJSON

func (r *RPCResponse) FastUnmarshalJSON(p []byte) error

func (*RPCResponse) IsLazySuccessResponse

func (r *RPCResponse) IsLazySuccessResponse() bool

func (*RPCResponse) MarshalJSON

func (r *RPCResponse) MarshalJSON() ([]byte, error)

func (*RPCResponse) ReleaseBuffer

func (r *RPCResponse) ReleaseBuffer()

type RoomChange

type RoomChange struct {
	PublicId    sharedTypes.PublicId `json:"i"`
	DisplayName string               `json:"n,omitempty"`
	IsJoin      uint8                `json:"j,omitempty"`
	HasEmitted  bool                 `json:"-"`
}

func (RoomChange) Append

func (r RoomChange) Append(p []byte) []byte

type RoomChanges

type RoomChanges []RoomChange

type WriteQueue

type WriteQueue chan WriteQueueEntry

type WriteQueueEntry

type WriteQueueEntry struct {
	RPCResponse *RPCResponse
	Msg         *websocket.PreparedMessage
	FatalError  bool
}

func PrepareBulkMessage

func PrepareBulkMessage(response *RPCResponse) (WriteQueueEntry, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL