internal

package
v0.0.0-...-7dde832 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ack      = "Ack"
	DocRes   = "DocRes"
	OpsRes   = "OpsRes"
	Error    = "Error"
	Outdated = "Outdated"
)
View Source
const (
	Add  = "Add"
	Del  = "Del"
	NOOP = "NOOP"
)
View Source
const (
	UpdateInterval = 250 * time.Millisecond
	SnapMult       = 100
)

Variables

This section is empty.

Functions

func Apply

func Apply(s []byte, ops []Op) []byte

applies a set of operations (in increasing Location order) to a byte slice

func Run

func Run(port int)

Types

type Claims

type Claims struct {
	Uid string `json:"uid"`
	jwt.StandardClaims
}

type Client

type Client struct {
	sync.Mutex // protects concurrent conn writes
	// contains filtered or unexported fields
}

type Credentials

type Credentials struct {
	Password string `json:"password"`
	Username string `json:"username"`
}

type Doc

type Doc struct {
	Body  []byte
	View  int
	DocId int64
}

func (*Doc) ApplyOps

func (d *Doc) ApplyOps(op []Op)

type DocMeta

type DocMeta struct {
	Doc Doc

	Log         [][]Op         // one update is a collection of ops from one diff
	NextSeq     map[string]int // expected next seq from user
	AppliedSeq  map[string]int // all seqs up to this from user have been applied
	NextDiscard int
	DocId       int64
	// contains filtered or unexported fields
}

type Op

type Op struct {
	Loc  int
	Type string
	Ch   byte
	Seq  int // purely for client-side

	Uid     string
	Session int64
}

func Xform

func Xform(o1, o2 []Op) []Op

operational transform o2 in the event that o1 gets applied first; both are in increasing Loc order

type Request

type Request struct {
	IsQuery bool
	DocId   int64
	Uid     string

	Ops  []Op
	View int
	Seq  int

	Num int
}

type Response

type Response struct {
	Type string
	View int
	Seq  int // last seen seq (always included)

	Body string // current document for DocRes
	Ops  [][]Op // ops since last view
}

type Server

type Server struct {
	Docs       map[int64]*DocMeta
	CommitLog  []Request // Paxos stand-in for now
	LastCommit int       // last req to have been saved to commit log
	// contains filtered or unexported fields
}

func NewServer

func NewServer(addr string, port int) *Server

func (*Server) NewClient

func (s *Server) NewClient(docId int64, uid string, conn *websocket.Conn) Client

Jump to

Keyboard shortcuts

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