protocol

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package protocol is a generated protocol buffer package.

It is generated from these files:
	internal/protocol/commands.proto

It has these top-level messages:
	Command
	Open
	Begin
	Frames
	FramesPage
	Undo
	End
	Checkpoint

package protocol implements serialization and deserialization logic for dqlite-specific Raft commands, that will be exeuted by the dqlite's FSM.

Example

Create a new dqlite Command with a few parameters, serialize it, and the finally deserialize it and read back its parameters.

package main

import (
	"fmt"
	"log"

	"github.com/CanonicalLtd/dqlite/internal/protocol"
)

func main() {
	data, err := protocol.MarshalCommand(protocol.NewOpen("test.db"))
	if err != nil {
		log.Fatalf("failed to marshal open command: %v", err)
	}
	cmd, err := protocol.UnmarshalCommand(data)
	if err != nil {
		log.Fatalf("failed to unmarshal open command: %v", err)
	}
	params := cmd.Payload.(*protocol.Command_Open)

	fmt.Println(len(data))
	fmt.Println(cmd.Name())
	fmt.Println(params.Open.Name)
}
Output:

11
open
test.db

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthCommands = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCommands   = fmt.Errorf("proto: integer overflow")
)

Functions

func MarshalCommand

func MarshalCommand(command *Command) ([]byte, error)

MarshalCommand marshals a dqlite FSM command.

Types

type Begin

type Begin struct {
	Txid uint64 `protobuf:"varint,1,opt,name=txid,proto3" json:"txid,omitempty"`
	Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
}

Parameters to begin a new write transaction.

This command is not used anymore, but it's kept for backward-compatibility.

func (*Begin) Descriptor

func (*Begin) Descriptor() ([]byte, []int)

func (*Begin) GetName

func (m *Begin) GetName() string

func (*Begin) GetTxid

func (m *Begin) GetTxid() uint64

func (*Begin) Marshal

func (m *Begin) Marshal() (dAtA []byte, err error)

func (*Begin) MarshalTo

func (m *Begin) MarshalTo(dAtA []byte) (int, error)

func (*Begin) ProtoMessage

func (*Begin) ProtoMessage()

func (*Begin) Reset

func (m *Begin) Reset()

func (*Begin) Size

func (m *Begin) Size() (n int)

func (*Begin) String

func (m *Begin) String() string

func (*Begin) Unmarshal

func (m *Begin) Unmarshal(dAtA []byte) error

type Checkpoint

type Checkpoint struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}

Parameters to perform a WAL checkpoint.

func (*Checkpoint) Descriptor

func (*Checkpoint) Descriptor() ([]byte, []int)

func (*Checkpoint) GetName

func (m *Checkpoint) GetName() string

func (*Checkpoint) Marshal

func (m *Checkpoint) Marshal() (dAtA []byte, err error)

func (*Checkpoint) MarshalTo

func (m *Checkpoint) MarshalTo(dAtA []byte) (int, error)

func (*Checkpoint) ProtoMessage

func (*Checkpoint) ProtoMessage()

func (*Checkpoint) Reset

func (m *Checkpoint) Reset()

func (*Checkpoint) Size

func (m *Checkpoint) Size() (n int)

func (*Checkpoint) String

func (m *Checkpoint) String() string

func (*Checkpoint) Unmarshal

func (m *Checkpoint) Unmarshal(dAtA []byte) error

type Command

type Command struct {
	// Types that are valid to be assigned to Payload:
	//	*Command_Open
	//	*Command_Begin
	//	*Command_Frames
	//	*Command_Undo
	//	*Command_End
	//	*Command_Checkpoint
	Payload isCommand_Payload `protobuf_oneof:"Payload"`
}

Command encapsulates the payload fo a dqlite Raft FSM command.

On the wire this will be a varint indentifying the command type, followed by the command payload.

func NewBegin

func NewBegin(txid uint64, name string) *Command

NewBegin returns a new Command with Begin parameters.

func NewCheckpoint

func NewCheckpoint(name string) *Command

NewCheckpoint returns a new Checkpoint protobuf message.

func NewEnd

func NewEnd(txid uint64) *Command

NewEnd returns a new End protobuf message.

func NewFrames

func NewFrames(txid uint64, filename string, frames *sqlite3.ReplicationFramesParams) *Command

NewFrames returns a new WalFrames protobuf message.

func NewOpen

func NewOpen(name string) *Command

NewOpen returns a new Command with Open parameters.

func NewUndo

func NewUndo(txid uint64) *Command

NewUndo returns a new Undo protobuf message.

func UnmarshalCommand

func UnmarshalCommand(data []byte) (*Command, error)

UnmarshalCommand unmarshals a dqlite FSM command.

func (*Command) Descriptor

func (*Command) Descriptor() ([]byte, []int)

func (*Command) GetBegin

func (m *Command) GetBegin() *Begin

func (*Command) GetCheckpoint

func (m *Command) GetCheckpoint() *Checkpoint

func (*Command) GetEnd

func (m *Command) GetEnd() *End

func (*Command) GetFrames

func (m *Command) GetFrames() *Frames

func (*Command) GetOpen

func (m *Command) GetOpen() *Open

func (*Command) GetPayload

func (m *Command) GetPayload() isCommand_Payload

func (*Command) GetUndo

func (m *Command) GetUndo() *Undo

func (*Command) Marshal

func (m *Command) Marshal() (dAtA []byte, err error)

func (*Command) MarshalTo

func (m *Command) MarshalTo(dAtA []byte) (int, error)

func (*Command) Name

func (c *Command) Name() string

Name returns a human readable name for the command, based on its Params type.

func (*Command) ProtoMessage

func (*Command) ProtoMessage()

func (*Command) Reset

func (m *Command) Reset()

func (*Command) Size

func (m *Command) Size() (n int)

func (*Command) String

func (m *Command) String() string

func (*Command) Unmarshal

func (m *Command) Unmarshal(dAtA []byte) error

func (*Command) XXX_OneofFuncs

func (*Command) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type Command_Begin

type Command_Begin struct {
	Begin *Begin `protobuf:"bytes,2,opt,name=begin,oneof"`
}

func (*Command_Begin) MarshalTo

func (m *Command_Begin) MarshalTo(dAtA []byte) (int, error)

func (*Command_Begin) Size

func (m *Command_Begin) Size() (n int)

type Command_Checkpoint

type Command_Checkpoint struct {
	Checkpoint *Checkpoint `protobuf:"bytes,6,opt,name=checkpoint,oneof"`
}

func (*Command_Checkpoint) MarshalTo

func (m *Command_Checkpoint) MarshalTo(dAtA []byte) (int, error)

func (*Command_Checkpoint) Size

func (m *Command_Checkpoint) Size() (n int)

type Command_End

type Command_End struct {
	End *End `protobuf:"bytes,5,opt,name=end,oneof"`
}

func (*Command_End) MarshalTo

func (m *Command_End) MarshalTo(dAtA []byte) (int, error)

func (*Command_End) Size

func (m *Command_End) Size() (n int)

type Command_Frames

type Command_Frames struct {
	Frames *Frames `protobuf:"bytes,3,opt,name=frames,oneof"`
}

func (*Command_Frames) MarshalTo

func (m *Command_Frames) MarshalTo(dAtA []byte) (int, error)

func (*Command_Frames) Size

func (m *Command_Frames) Size() (n int)

type Command_Open

type Command_Open struct {
	Open *Open `protobuf:"bytes,1,opt,name=open,oneof"`
}

func (*Command_Open) MarshalTo

func (m *Command_Open) MarshalTo(dAtA []byte) (int, error)

func (*Command_Open) Size

func (m *Command_Open) Size() (n int)

type Command_Undo

type Command_Undo struct {
	Undo *Undo `protobuf:"bytes,4,opt,name=undo,oneof"`
}

func (*Command_Undo) MarshalTo

func (m *Command_Undo) MarshalTo(dAtA []byte) (int, error)

func (*Command_Undo) Size

func (m *Command_Undo) Size() (n int)

type End

type End struct {
	Txid uint64 `protobuf:"varint,1,opt,name=txid,proto3" json:"txid,omitempty"`
}

Parameters to end a write transaction, and update the WAL commit pointer.

This command is not used anymore, but it's kept for backward-compatibility.

func (*End) Descriptor

func (*End) Descriptor() ([]byte, []int)

func (*End) GetTxid

func (m *End) GetTxid() uint64

func (*End) Marshal

func (m *End) Marshal() (dAtA []byte, err error)

func (*End) MarshalTo

func (m *End) MarshalTo(dAtA []byte) (int, error)

func (*End) ProtoMessage

func (*End) ProtoMessage()

func (*End) Reset

func (m *End) Reset()

func (*End) Size

func (m *End) Size() (n int)

func (*End) String

func (m *End) String() string

func (*End) Unmarshal

func (m *End) Unmarshal(dAtA []byte) error

type Frames

type Frames struct {
	Txid      uint64        `protobuf:"varint,1,opt,name=txid,proto3" json:"txid,omitempty"`
	PageSize  int32         `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
	Pages     []*FramesPage `protobuf:"bytes,3,rep,name=pages" json:"pages,omitempty"`
	Truncate  uint32        `protobuf:"varint,4,opt,name=truncate,proto3" json:"truncate,omitempty"`
	IsCommit  int32         `protobuf:"varint,5,opt,name=is_commit,json=isCommit,proto3" json:"is_commit,omitempty"`
	SyncFlags uint32        `protobuf:"varint,6,opt,name=sync_flags,json=syncFlags,proto3" json:"sync_flags,omitempty"`
	Filename  string        `protobuf:"bytes,7,opt,name=filename,proto3" json:"filename,omitempty"`
}

Parameters to append new frames to the WAL within a write transaction.

func (*Frames) Descriptor

func (*Frames) Descriptor() ([]byte, []int)

func (*Frames) GetFilename

func (m *Frames) GetFilename() string

func (*Frames) GetIsCommit

func (m *Frames) GetIsCommit() int32

func (*Frames) GetPageSize

func (m *Frames) GetPageSize() int32

func (*Frames) GetPages

func (m *Frames) GetPages() []*FramesPage

func (*Frames) GetSyncFlags

func (m *Frames) GetSyncFlags() uint32

func (*Frames) GetTruncate

func (m *Frames) GetTruncate() uint32

func (*Frames) GetTxid

func (m *Frames) GetTxid() uint64

func (*Frames) Marshal

func (m *Frames) Marshal() (dAtA []byte, err error)

func (*Frames) MarshalTo

func (m *Frames) MarshalTo(dAtA []byte) (int, error)

func (*Frames) ProtoMessage

func (*Frames) ProtoMessage()

func (*Frames) Reset

func (m *Frames) Reset()

func (*Frames) Size

func (m *Frames) Size() (n int)

func (*Frames) String

func (m *Frames) String() string

func (*Frames) Unmarshal

func (m *Frames) Unmarshal(dAtA []byte) error

type FramesPage

type FramesPage struct {
	Data   []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	Flags  uint32 `protobuf:"varint,2,opt,name=flags,proto3" json:"flags,omitempty"`
	Number uint32 `protobuf:"varint,3,opt,name=number,proto3" json:"number,omitempty"`
}

A single frame of data in a Frames command.

func (*FramesPage) Descriptor

func (*FramesPage) Descriptor() ([]byte, []int)

func (*FramesPage) GetData

func (m *FramesPage) GetData() []byte

func (*FramesPage) GetFlags

func (m *FramesPage) GetFlags() uint32

func (*FramesPage) GetNumber

func (m *FramesPage) GetNumber() uint32

func (*FramesPage) Marshal

func (m *FramesPage) Marshal() (dAtA []byte, err error)

func (*FramesPage) MarshalTo

func (m *FramesPage) MarshalTo(dAtA []byte) (int, error)

func (*FramesPage) ProtoMessage

func (*FramesPage) ProtoMessage()

func (*FramesPage) Reset

func (m *FramesPage) Reset()

func (*FramesPage) Size

func (m *FramesPage) Size() (n int)

func (*FramesPage) String

func (m *FramesPage) String() string

func (*FramesPage) Unmarshal

func (m *FramesPage) Unmarshal(dAtA []byte) error

type Open

type Open struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}

Parameters to open a new database and setup the needed data structures for replication.

func (*Open) Descriptor

func (*Open) Descriptor() ([]byte, []int)

func (*Open) GetName

func (m *Open) GetName() string

func (*Open) Marshal

func (m *Open) Marshal() (dAtA []byte, err error)

func (*Open) MarshalTo

func (m *Open) MarshalTo(dAtA []byte) (int, error)

func (*Open) ProtoMessage

func (*Open) ProtoMessage()

func (*Open) Reset

func (m *Open) Reset()

func (*Open) Size

func (m *Open) Size() (n int)

func (*Open) String

func (m *Open) String() string

func (*Open) Unmarshal

func (m *Open) Unmarshal(dAtA []byte) error

type Undo

type Undo struct {
	Txid uint64 `protobuf:"varint,1,opt,name=txid,proto3" json:"txid,omitempty"`
}

Parameters to undo any previous WAL change in a write transaction.

func (*Undo) Descriptor

func (*Undo) Descriptor() ([]byte, []int)

func (*Undo) GetTxid

func (m *Undo) GetTxid() uint64

func (*Undo) Marshal

func (m *Undo) Marshal() (dAtA []byte, err error)

func (*Undo) MarshalTo

func (m *Undo) MarshalTo(dAtA []byte) (int, error)

func (*Undo) ProtoMessage

func (*Undo) ProtoMessage()

func (*Undo) Reset

func (m *Undo) Reset()

func (*Undo) Size

func (m *Undo) Size() (n int)

func (*Undo) String

func (m *Undo) String() string

func (*Undo) Unmarshal

func (m *Undo) Unmarshal(dAtA []byte) error

Jump to

Keyboard shortcuts

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