counter

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

Type is the counter primitive type

Variables

View Source
var (
	ErrInvalidLengthCounter        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCounter          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupCounter = fmt.Errorf("proto: unexpected end of group")
)

Functions

func RegisterPrimitive added in v0.3.0

func RegisterPrimitive(node *atomix.Node)

RegisterPrimitive registers the primitive on the given node

Types

type CheckAndSetRequest

type CheckAndSetRequest struct {
	Expect int64 `protobuf:"varint,1,opt,name=expect,proto3" json:"expect,omitempty"`
	Update int64 `protobuf:"varint,2,opt,name=update,proto3" json:"update,omitempty"`
}

func (*CheckAndSetRequest) Descriptor

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

func (*CheckAndSetRequest) GetExpect

func (m *CheckAndSetRequest) GetExpect() int64

func (*CheckAndSetRequest) GetUpdate

func (m *CheckAndSetRequest) GetUpdate() int64

func (*CheckAndSetRequest) Marshal

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

func (*CheckAndSetRequest) MarshalTo

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

func (*CheckAndSetRequest) MarshalToSizedBuffer

func (m *CheckAndSetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CheckAndSetRequest) ProtoMessage

func (*CheckAndSetRequest) ProtoMessage()

func (*CheckAndSetRequest) Reset

func (m *CheckAndSetRequest) Reset()

func (*CheckAndSetRequest) Size

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

func (*CheckAndSetRequest) String

func (m *CheckAndSetRequest) String() string

func (*CheckAndSetRequest) Unmarshal

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

func (*CheckAndSetRequest) XXX_DiscardUnknown

func (m *CheckAndSetRequest) XXX_DiscardUnknown()

func (*CheckAndSetRequest) XXX_Marshal

func (m *CheckAndSetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CheckAndSetRequest) XXX_Merge

func (m *CheckAndSetRequest) XXX_Merge(src proto.Message)

func (*CheckAndSetRequest) XXX_Size

func (m *CheckAndSetRequest) XXX_Size() int

func (*CheckAndSetRequest) XXX_Unmarshal

func (m *CheckAndSetRequest) XXX_Unmarshal(b []byte) error

type CheckAndSetResponse

type CheckAndSetResponse struct {
	Succeeded bool `protobuf:"varint,1,opt,name=succeeded,proto3" json:"succeeded,omitempty"`
}

func (*CheckAndSetResponse) Descriptor

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

func (*CheckAndSetResponse) GetSucceeded

func (m *CheckAndSetResponse) GetSucceeded() bool

func (*CheckAndSetResponse) Marshal

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

func (*CheckAndSetResponse) MarshalTo

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

func (*CheckAndSetResponse) MarshalToSizedBuffer

func (m *CheckAndSetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CheckAndSetResponse) ProtoMessage

func (*CheckAndSetResponse) ProtoMessage()

func (*CheckAndSetResponse) Reset

func (m *CheckAndSetResponse) Reset()

func (*CheckAndSetResponse) Size

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

func (*CheckAndSetResponse) String

func (m *CheckAndSetResponse) String() string

func (*CheckAndSetResponse) Unmarshal

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

func (*CheckAndSetResponse) XXX_DiscardUnknown

func (m *CheckAndSetResponse) XXX_DiscardUnknown()

func (*CheckAndSetResponse) XXX_Marshal

func (m *CheckAndSetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CheckAndSetResponse) XXX_Merge

func (m *CheckAndSetResponse) XXX_Merge(src proto.Message)

func (*CheckAndSetResponse) XXX_Size

func (m *CheckAndSetResponse) XXX_Size() int

func (*CheckAndSetResponse) XXX_Unmarshal

func (m *CheckAndSetResponse) XXX_Unmarshal(b []byte) error

type CounterSnapshot

type CounterSnapshot struct {
	Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}

Counter snapshot

func (*CounterSnapshot) Descriptor

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

func (*CounterSnapshot) GetValue

func (m *CounterSnapshot) GetValue() int64

func (*CounterSnapshot) Marshal

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

func (*CounterSnapshot) MarshalTo

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

func (*CounterSnapshot) MarshalToSizedBuffer

func (m *CounterSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CounterSnapshot) ProtoMessage

func (*CounterSnapshot) ProtoMessage()

func (*CounterSnapshot) Reset

func (m *CounterSnapshot) Reset()

func (*CounterSnapshot) Size

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

func (*CounterSnapshot) String

func (m *CounterSnapshot) String() string

func (*CounterSnapshot) Unmarshal

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

func (*CounterSnapshot) XXX_DiscardUnknown

func (m *CounterSnapshot) XXX_DiscardUnknown()

func (*CounterSnapshot) XXX_Marshal

func (m *CounterSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CounterSnapshot) XXX_Merge

func (m *CounterSnapshot) XXX_Merge(src proto.Message)

func (*CounterSnapshot) XXX_Size

func (m *CounterSnapshot) XXX_Size() int

func (*CounterSnapshot) XXX_Unmarshal

func (m *CounterSnapshot) XXX_Unmarshal(b []byte) error

type DecrementRequest

type DecrementRequest struct {
	Delta int64 `protobuf:"varint,1,opt,name=delta,proto3" json:"delta,omitempty"`
}

func (*DecrementRequest) Descriptor

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

func (*DecrementRequest) GetDelta

func (m *DecrementRequest) GetDelta() int64

func (*DecrementRequest) Marshal

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

func (*DecrementRequest) MarshalTo

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

func (*DecrementRequest) MarshalToSizedBuffer

func (m *DecrementRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*DecrementRequest) ProtoMessage

func (*DecrementRequest) ProtoMessage()

func (*DecrementRequest) Reset

func (m *DecrementRequest) Reset()

func (*DecrementRequest) Size

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

func (*DecrementRequest) String

func (m *DecrementRequest) String() string

func (*DecrementRequest) Unmarshal

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

func (*DecrementRequest) XXX_DiscardUnknown

func (m *DecrementRequest) XXX_DiscardUnknown()

func (*DecrementRequest) XXX_Marshal

func (m *DecrementRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DecrementRequest) XXX_Merge

func (m *DecrementRequest) XXX_Merge(src proto.Message)

func (*DecrementRequest) XXX_Size

func (m *DecrementRequest) XXX_Size() int

func (*DecrementRequest) XXX_Unmarshal

func (m *DecrementRequest) XXX_Unmarshal(b []byte) error

type DecrementResponse

type DecrementResponse struct {
	PreviousValue int64 `protobuf:"varint,1,opt,name=previous_value,json=previousValue,proto3" json:"previous_value,omitempty"`
	NextValue     int64 `protobuf:"varint,2,opt,name=next_value,json=nextValue,proto3" json:"next_value,omitempty"`
}

func (*DecrementResponse) Descriptor

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

func (*DecrementResponse) GetNextValue

func (m *DecrementResponse) GetNextValue() int64

func (*DecrementResponse) GetPreviousValue

func (m *DecrementResponse) GetPreviousValue() int64

func (*DecrementResponse) Marshal

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

func (*DecrementResponse) MarshalTo

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

func (*DecrementResponse) MarshalToSizedBuffer

func (m *DecrementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*DecrementResponse) ProtoMessage

func (*DecrementResponse) ProtoMessage()

func (*DecrementResponse) Reset

func (m *DecrementResponse) Reset()

func (*DecrementResponse) Size

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

func (*DecrementResponse) String

func (m *DecrementResponse) String() string

func (*DecrementResponse) Unmarshal

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

func (*DecrementResponse) XXX_DiscardUnknown

func (m *DecrementResponse) XXX_DiscardUnknown()

func (*DecrementResponse) XXX_Marshal

func (m *DecrementResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DecrementResponse) XXX_Merge

func (m *DecrementResponse) XXX_Merge(src proto.Message)

func (*DecrementResponse) XXX_Size

func (m *DecrementResponse) XXX_Size() int

func (*DecrementResponse) XXX_Unmarshal

func (m *DecrementResponse) XXX_Unmarshal(b []byte) error

type GetRequest

type GetRequest struct {
}

func (*GetRequest) Descriptor

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

func (*GetRequest) Marshal

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

func (*GetRequest) MarshalTo

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

func (*GetRequest) MarshalToSizedBuffer

func (m *GetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) Reset

func (m *GetRequest) Reset()

func (*GetRequest) Size

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

func (*GetRequest) String

func (m *GetRequest) String() string

func (*GetRequest) Unmarshal

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

func (*GetRequest) XXX_DiscardUnknown

func (m *GetRequest) XXX_DiscardUnknown()

func (*GetRequest) XXX_Marshal

func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetRequest) XXX_Merge

func (m *GetRequest) XXX_Merge(src proto.Message)

func (*GetRequest) XXX_Size

func (m *GetRequest) XXX_Size() int

func (*GetRequest) XXX_Unmarshal

func (m *GetRequest) XXX_Unmarshal(b []byte) error

type GetResponse

type GetResponse struct {
	Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}

func (*GetResponse) Descriptor

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

func (*GetResponse) GetValue

func (m *GetResponse) GetValue() int64

func (*GetResponse) Marshal

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

func (*GetResponse) MarshalTo

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

func (*GetResponse) MarshalToSizedBuffer

func (m *GetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GetResponse) ProtoMessage

func (*GetResponse) ProtoMessage()

func (*GetResponse) Reset

func (m *GetResponse) Reset()

func (*GetResponse) Size

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

func (*GetResponse) String

func (m *GetResponse) String() string

func (*GetResponse) Unmarshal

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

func (*GetResponse) XXX_DiscardUnknown

func (m *GetResponse) XXX_DiscardUnknown()

func (*GetResponse) XXX_Marshal

func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GetResponse) XXX_Merge

func (m *GetResponse) XXX_Merge(src proto.Message)

func (*GetResponse) XXX_Size

func (m *GetResponse) XXX_Size() int

func (*GetResponse) XXX_Unmarshal

func (m *GetResponse) XXX_Unmarshal(b []byte) error

type IncrementRequest

type IncrementRequest struct {
	Delta int64 `protobuf:"varint,1,opt,name=delta,proto3" json:"delta,omitempty"`
}

func (*IncrementRequest) Descriptor

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

func (*IncrementRequest) GetDelta

func (m *IncrementRequest) GetDelta() int64

func (*IncrementRequest) Marshal

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

func (*IncrementRequest) MarshalTo

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

func (*IncrementRequest) MarshalToSizedBuffer

func (m *IncrementRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*IncrementRequest) ProtoMessage

func (*IncrementRequest) ProtoMessage()

func (*IncrementRequest) Reset

func (m *IncrementRequest) Reset()

func (*IncrementRequest) Size

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

func (*IncrementRequest) String

func (m *IncrementRequest) String() string

func (*IncrementRequest) Unmarshal

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

func (*IncrementRequest) XXX_DiscardUnknown

func (m *IncrementRequest) XXX_DiscardUnknown()

func (*IncrementRequest) XXX_Marshal

func (m *IncrementRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*IncrementRequest) XXX_Merge

func (m *IncrementRequest) XXX_Merge(src proto.Message)

func (*IncrementRequest) XXX_Size

func (m *IncrementRequest) XXX_Size() int

func (*IncrementRequest) XXX_Unmarshal

func (m *IncrementRequest) XXX_Unmarshal(b []byte) error

type IncrementResponse

type IncrementResponse struct {
	PreviousValue int64 `protobuf:"varint,1,opt,name=previous_value,json=previousValue,proto3" json:"previous_value,omitempty"`
	NextValue     int64 `protobuf:"varint,2,opt,name=next_value,json=nextValue,proto3" json:"next_value,omitempty"`
}

func (*IncrementResponse) Descriptor

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

func (*IncrementResponse) GetNextValue

func (m *IncrementResponse) GetNextValue() int64

func (*IncrementResponse) GetPreviousValue

func (m *IncrementResponse) GetPreviousValue() int64

func (*IncrementResponse) Marshal

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

func (*IncrementResponse) MarshalTo

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

func (*IncrementResponse) MarshalToSizedBuffer

func (m *IncrementResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*IncrementResponse) ProtoMessage

func (*IncrementResponse) ProtoMessage()

func (*IncrementResponse) Reset

func (m *IncrementResponse) Reset()

func (*IncrementResponse) Size

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

func (*IncrementResponse) String

func (m *IncrementResponse) String() string

func (*IncrementResponse) Unmarshal

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

func (*IncrementResponse) XXX_DiscardUnknown

func (m *IncrementResponse) XXX_DiscardUnknown()

func (*IncrementResponse) XXX_Marshal

func (m *IncrementResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*IncrementResponse) XXX_Merge

func (m *IncrementResponse) XXX_Merge(src proto.Message)

func (*IncrementResponse) XXX_Size

func (m *IncrementResponse) XXX_Size() int

func (*IncrementResponse) XXX_Unmarshal

func (m *IncrementResponse) XXX_Unmarshal(b []byte) error

type Primitive added in v0.3.0

type Primitive struct{}

Primitive is the counter primitive

func (*Primitive) NewService added in v0.3.0

func (p *Primitive) NewService(scheduler primitive.Scheduler, context primitive.ServiceContext) primitive.Service

NewService creates a new counter service

func (*Primitive) RegisterServer added in v0.3.0

func (p *Primitive) RegisterServer(server *grpc.Server, protocol primitive.Protocol)

RegisterServer registers the counter server with the protocol

type Server

type Server struct {
	*primitive.Server
}

Server is an implementation of CounterServiceServer for the counter primitive

func (*Server) CheckAndSet

func (s *Server) CheckAndSet(ctx context.Context, request *api.CheckAndSetRequest) (*api.CheckAndSetResponse, error)

CheckAndSet updates the value of the counter conditionally

func (*Server) Close

func (s *Server) Close(ctx context.Context, request *api.CloseRequest) (*api.CloseResponse, error)

Close closes a session

func (*Server) Create

func (s *Server) Create(ctx context.Context, request *api.CreateRequest) (*api.CreateResponse, error)

Create opens a new session

func (*Server) Decrement

func (s *Server) Decrement(ctx context.Context, request *api.DecrementRequest) (*api.DecrementResponse, error)

Decrement decrements the value of the counter by a delta

func (*Server) Get

func (s *Server) Get(ctx context.Context, request *api.GetRequest) (*api.GetResponse, error)

Get gets the current value of the counter

func (*Server) Increment

func (s *Server) Increment(ctx context.Context, request *api.IncrementRequest) (*api.IncrementResponse, error)

Increment increments the value of the counter by a delta

func (*Server) Set

func (s *Server) Set(ctx context.Context, request *api.SetRequest) (*api.SetResponse, error)

Set sets the current value of the counter

type Service

type Service struct {
	primitive.Service
	// contains filtered or unexported fields
}

Service is a state machine for a counter primitive

func (*Service) Backup

func (c *Service) Backup(writer io.Writer) error

Backup backs up the service

func (*Service) CAS

func (c *Service) CAS(bytes []byte) ([]byte, error)

CAS updates the value of the counter if it matches a current value

func (*Service) Decrement

func (c *Service) Decrement(bytes []byte) ([]byte, error)

Decrement decrements the value of the counter by a delta

func (*Service) Get

func (c *Service) Get(bytes []byte) ([]byte, error)

Get gets the current value of the counter

func (*Service) Increment

func (c *Service) Increment(bytes []byte) ([]byte, error)

Increment increments the value of the counter by a delta

func (*Service) Restore

func (c *Service) Restore(reader io.Reader) error

Restore restores the service from a backup

func (*Service) Set

func (c *Service) Set(bytes []byte) ([]byte, error)

Set sets the value of the counter

type SetRequest

type SetRequest struct {
	Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
}

func (*SetRequest) Descriptor

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

func (*SetRequest) GetValue

func (m *SetRequest) GetValue() int64

func (*SetRequest) Marshal

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

func (*SetRequest) MarshalTo

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

func (*SetRequest) MarshalToSizedBuffer

func (m *SetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SetRequest) ProtoMessage

func (*SetRequest) ProtoMessage()

func (*SetRequest) Reset

func (m *SetRequest) Reset()

func (*SetRequest) Size

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

func (*SetRequest) String

func (m *SetRequest) String() string

func (*SetRequest) Unmarshal

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

func (*SetRequest) XXX_DiscardUnknown

func (m *SetRequest) XXX_DiscardUnknown()

func (*SetRequest) XXX_Marshal

func (m *SetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SetRequest) XXX_Merge

func (m *SetRequest) XXX_Merge(src proto.Message)

func (*SetRequest) XXX_Size

func (m *SetRequest) XXX_Size() int

func (*SetRequest) XXX_Unmarshal

func (m *SetRequest) XXX_Unmarshal(b []byte) error

type SetResponse

type SetResponse struct {
	PreviousValue int64 `protobuf:"varint,1,opt,name=previous_value,json=previousValue,proto3" json:"previous_value,omitempty"`
}

func (*SetResponse) Descriptor

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

func (*SetResponse) GetPreviousValue

func (m *SetResponse) GetPreviousValue() int64

func (*SetResponse) Marshal

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

func (*SetResponse) MarshalTo

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

func (*SetResponse) MarshalToSizedBuffer

func (m *SetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*SetResponse) ProtoMessage

func (*SetResponse) ProtoMessage()

func (*SetResponse) Reset

func (m *SetResponse) Reset()

func (*SetResponse) Size

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

func (*SetResponse) String

func (m *SetResponse) String() string

func (*SetResponse) Unmarshal

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

func (*SetResponse) XXX_DiscardUnknown

func (m *SetResponse) XXX_DiscardUnknown()

func (*SetResponse) XXX_Marshal

func (m *SetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SetResponse) XXX_Merge

func (m *SetResponse) XXX_Merge(src proto.Message)

func (*SetResponse) XXX_Size

func (m *SetResponse) XXX_Size() int

func (*SetResponse) XXX_Unmarshal

func (m *SetResponse) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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