Help us shape the future of Go! Take the 2026 Go Developer Survey

sharingstate

package
v0.57.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ViewerRole

func ViewerRole(state *sobject.SOState, peerID string) sobject.SOParticipantRole

ViewerRole returns the current viewer's effective participant role.

Types

type MailboxEntry

type MailboxEntry struct {
	ID        int64
	InviteID  string
	PeerID    string
	Status    string
	CreatedAt int64
	AccountID string
	EntityID  string
}

MailboxEntry contains mailbox metadata needed by sharing state projection.

type ParticipantInfo

type ParticipantInfo struct {
	AccountID string
	EntityID  string
	PeerIDs   []string
	Role      sobject.SOParticipantRole
	IsSelf    bool
}

ParticipantInfo is the app-facing participant presentation row.

func BuildParticipantInfo

func BuildParticipantInfo(
	soState *sobject.SOState,
	selfPeerID string,
	presentation *ParticipantPresentation,
) []*ParticipantInfo

BuildParticipantInfo groups participant rows by account or peer identity.

type ParticipantPresentation

type ParticipantPresentation struct {
	SelfAccountID string
	SelfEntityID  string
	AccountLabels map[string]string
}

ParticipantPresentation contains account labels used by sharing rows.

type SharingState

type SharingState struct {
	// Participants is the canonical SharedObject audience.
	Participants []*sobject.SOParticipantConfig
	// Invites contains the owner's current invitation records.
	Invites []*sobject.SOInvite
	// MailboxEntries contains pending invitation delivery metadata.
	MailboxEntries []*MailboxEntry
	// ViewerRole is the mounted participant's effective role.
	ViewerRole sobject.SOParticipantRole
	// CanManage indicates that the mounted participant may manage sharing.
	CanManage bool
	// ParticipantInfo groups participant presentation without conferring authority.
	ParticipantInfo []*ParticipantInfo
	// ConfigChainHash identifies the latest verified configuration entry.
	ConfigChainHash []byte
	// ConfigChainSeqno is the owner's configuration sequence number.
	ConfigChainSeqno uint64
	// ViewerPeerID is the authenticated participant of the mounted SharedObject.
	ViewerPeerID string
}

SharingState contains the sharing snapshot for a space.

func (*SharingState) Equal

func (s *SharingState) Equal(that *SharingState) bool

Equal reports whether two sharing snapshots contain the same projected values.

type State

type State struct {
	// contains filtered or unexported fields
}

State carries every input snapshot the sharing watch reads per emission.

func NewState

func NewState(
	soState *sobject.SOState,
	mailboxEntries []*MailboxEntry,
	presentation *ParticipantPresentation,
) *State

NewState constructs a State from the first sharing snapshot.

func (*State) BridgeSOState

func (s *State) BridgeSOState(
	ctx context.Context,
	soStateCtr ccontainer.Watchable[*sobject.SOState],
)

BridgeSOState forwards SO state container updates into the local broadcast.

func (*State) RunWatchLoop

func (s *State) RunWatchLoop(
	ctx context.Context,
	peerID string,
	send func(*SharingState) error,
) error

RunWatchLoop emits a fresh SpaceSharingState whenever any folded source changes.

func (*State) SetMailboxEntries

func (s *State) SetMailboxEntries(entries []*MailboxEntry)

SetMailboxEntries updates mailbox entries and wakes watchers.

func (*State) SetSOState

func (s *State) SetSOState(next *sobject.SOState)

SetSOState updates the shared object state snapshot and wakes watchers.

Jump to

Keyboard shortcuts

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