databroker

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 29 Imported by: 6

Documentation

Overview

Package databroker contains databroker protobuf definitions.

Index

Constants

This section is empty.

Variables

View Source
var File_databroker_proto protoreflect.FileDescriptor

Functions

func Get added in v0.17.0

func Get(ctx context.Context, client DataBrokerServiceClient, object recordObject) error

Get gets a record from the databroker and unmarshals it into the object.

func GetViaJSON added in v0.20.0

func GetViaJSON[T any](ctx context.Context, client DataBrokerServiceClient, recordType, recordID string) (*T, error)

GetViaJSON gets a record from the databroker, marshals it to JSON, and then unmarshals it to the given type.

func IsNotFound added in v0.25.0

func IsNotFound(err error) bool

IsNotFound returns true if the error is a not found error.

func PutMulti added in v0.24.0

func PutMulti(ctx context.Context, client DataBrokerServiceClient, records ...*Record) error

PutMulti puts the records into the databroker in batches.

func RegisterDataBrokerServiceServer

func RegisterDataBrokerServiceServer(s *grpc.Server, srv DataBrokerServiceServer)

Types

type AcquireLeaseRequest added in v0.15.0

type AcquireLeaseRequest struct {

	// Name is the name of the lease. Only a single client can hold the lease on
	// the specified name at any one time.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Duration is the duration of the lease. After the duration is reached the
	// lease can be acquired by other clients.
	Duration *durationpb.Duration `protobuf:"bytes,2,opt,name=duration,proto3" json:"duration,omitempty"`
	// contains filtered or unexported fields
}

func (*AcquireLeaseRequest) Descriptor deprecated added in v0.15.0

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

Deprecated: Use AcquireLeaseRequest.ProtoReflect.Descriptor instead.

func (*AcquireLeaseRequest) GetDuration added in v0.15.0

func (x *AcquireLeaseRequest) GetDuration() *durationpb.Duration

func (*AcquireLeaseRequest) GetName added in v0.15.0

func (x *AcquireLeaseRequest) GetName() string

func (*AcquireLeaseRequest) ProtoMessage added in v0.15.0

func (*AcquireLeaseRequest) ProtoMessage()

func (*AcquireLeaseRequest) ProtoReflect added in v0.15.0

func (x *AcquireLeaseRequest) ProtoReflect() protoreflect.Message

func (*AcquireLeaseRequest) Reset added in v0.15.0

func (x *AcquireLeaseRequest) Reset()

func (*AcquireLeaseRequest) String added in v0.15.0

func (x *AcquireLeaseRequest) String() string

type AcquireLeaseResponse added in v0.15.0

type AcquireLeaseResponse struct {

	// Id is the id of the acquired lease. Subsequent calls to release or renew
	// will need both the lease name and the lease id.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*AcquireLeaseResponse) Descriptor deprecated added in v0.15.0

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

Deprecated: Use AcquireLeaseResponse.ProtoReflect.Descriptor instead.

func (*AcquireLeaseResponse) GetId added in v0.15.0

func (x *AcquireLeaseResponse) GetId() string

func (*AcquireLeaseResponse) ProtoMessage added in v0.15.0

func (*AcquireLeaseResponse) ProtoMessage()

func (*AcquireLeaseResponse) ProtoReflect added in v0.15.0

func (x *AcquireLeaseResponse) ProtoReflect() protoreflect.Message

func (*AcquireLeaseResponse) Reset added in v0.15.0

func (x *AcquireLeaseResponse) Reset()

func (*AcquireLeaseResponse) String added in v0.15.0

func (x *AcquireLeaseResponse) String() string

type DataBrokerServiceClient

type DataBrokerServiceClient interface {
	// AcquireLease acquires a distributed mutex lease.
	AcquireLease(ctx context.Context, in *AcquireLeaseRequest, opts ...grpc.CallOption) (*AcquireLeaseResponse, error)
	// Get gets a record.
	Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
	// ListTypes lists all the known record types.
	ListTypes(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ListTypesResponse, error)
	// Put saves a record.
	Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error)
	// Patch updates specific fields of an existing record.
	Patch(ctx context.Context, in *PatchRequest, opts ...grpc.CallOption) (*PatchResponse, error)
	// Query queries for records.
	Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)
	// ReleaseLease releases a distributed mutex lease.
	ReleaseLease(ctx context.Context, in *ReleaseLeaseRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// RenewLease renews a distributed mutex lease.
	RenewLease(ctx context.Context, in *RenewLeaseRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// SetOptions sets the options for a type in the databroker.
	SetOptions(ctx context.Context, in *SetOptionsRequest, opts ...grpc.CallOption) (*SetOptionsResponse, error)
	// Sync streams changes to records after the specified version.
	Sync(ctx context.Context, in *SyncRequest, opts ...grpc.CallOption) (DataBrokerService_SyncClient, error)
	// SyncLatest streams the latest version of every record.
	SyncLatest(ctx context.Context, in *SyncLatestRequest, opts ...grpc.CallOption) (DataBrokerService_SyncLatestClient, error)
}

DataBrokerServiceClient is the client API for DataBrokerService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

type DataBrokerServiceServer

type DataBrokerServiceServer interface {
	// AcquireLease acquires a distributed mutex lease.
	AcquireLease(context.Context, *AcquireLeaseRequest) (*AcquireLeaseResponse, error)
	// Get gets a record.
	Get(context.Context, *GetRequest) (*GetResponse, error)
	// ListTypes lists all the known record types.
	ListTypes(context.Context, *emptypb.Empty) (*ListTypesResponse, error)
	// Put saves a record.
	Put(context.Context, *PutRequest) (*PutResponse, error)
	// Patch updates specific fields of an existing record.
	Patch(context.Context, *PatchRequest) (*PatchResponse, error)
	// Query queries for records.
	Query(context.Context, *QueryRequest) (*QueryResponse, error)
	// ReleaseLease releases a distributed mutex lease.
	ReleaseLease(context.Context, *ReleaseLeaseRequest) (*emptypb.Empty, error)
	// RenewLease renews a distributed mutex lease.
	RenewLease(context.Context, *RenewLeaseRequest) (*emptypb.Empty, error)
	// SetOptions sets the options for a type in the databroker.
	SetOptions(context.Context, *SetOptionsRequest) (*SetOptionsResponse, error)
	// Sync streams changes to records after the specified version.
	Sync(*SyncRequest, DataBrokerService_SyncServer) error
	// SyncLatest streams the latest version of every record.
	SyncLatest(*SyncLatestRequest, DataBrokerService_SyncLatestServer) error
}

DataBrokerServiceServer is the server API for DataBrokerService service.

type DataBrokerService_SyncClient

type DataBrokerService_SyncClient interface {
	Recv() (*SyncResponse, error)
	grpc.ClientStream
}

type DataBrokerService_SyncLatestClient added in v0.14.0

type DataBrokerService_SyncLatestClient interface {
	Recv() (*SyncLatestResponse, error)
	grpc.ClientStream
}

type DataBrokerService_SyncLatestServer added in v0.14.0

type DataBrokerService_SyncLatestServer interface {
	Send(*SyncLatestResponse) error
	grpc.ServerStream
}

type DataBrokerService_SyncServer

type DataBrokerService_SyncServer interface {
	Send(*SyncResponse) error
	grpc.ServerStream
}

type GetRequest

type GetRequest struct {
	Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Id   string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetRequest) Descriptor deprecated

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

Deprecated: Use GetRequest.ProtoReflect.Descriptor instead.

func (*GetRequest) GetId

func (x *GetRequest) GetId() string

func (*GetRequest) GetType

func (x *GetRequest) GetType() string

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) ProtoReflect

func (x *GetRequest) ProtoReflect() protoreflect.Message

func (*GetRequest) Reset

func (x *GetRequest) Reset()

func (*GetRequest) String

func (x *GetRequest) String() string

type GetResponse

type GetResponse struct {
	Record *Record `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"`
	// contains filtered or unexported fields
}

func (*GetResponse) Descriptor deprecated

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

Deprecated: Use GetResponse.ProtoReflect.Descriptor instead.

func (*GetResponse) GetRecord

func (x *GetResponse) GetRecord() *Record

func (*GetResponse) ProtoMessage

func (*GetResponse) ProtoMessage()

func (*GetResponse) ProtoReflect

func (x *GetResponse) ProtoReflect() protoreflect.Message

func (*GetResponse) Reset

func (x *GetResponse) Reset()

func (*GetResponse) String

func (x *GetResponse) String() string

type Leaser added in v0.15.0

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

A Leaser attempts to acquire a lease and if successful runs the handler. If the lease is released the context used for the handler will be canceled and a new lease acquisition will be attempted.

func NewLeaser added in v0.15.0

func NewLeaser(leaseName string, ttl time.Duration, handler LeaserHandler) *Leaser

NewLeaser creates a new Leaser.

func NewLeasers added in v0.17.3

func NewLeasers(leaseName string, ttl time.Duration, client DataBrokerServiceClient, handlers ...func(context.Context) error) *Leaser

NewLeasers creates a leaser using multiple handler functions

func (*Leaser) Run added in v0.15.0

func (locker *Leaser) Run(ctx context.Context) error

Run acquires the lease and runs the handler. This continues until either:

1. ctx is canceled 2. a non-cancel error is returned from handler

type LeaserHandler added in v0.15.0

type LeaserHandler interface {
	GetDataBrokerServiceClient() DataBrokerServiceClient
	RunLeased(ctx context.Context) error
}

A LeaserHandler is a handler for the locker.

type ListTypesResponse added in v0.22.0

type ListTypesResponse struct {
	Types []string `protobuf:"bytes,1,rep,name=types,proto3" json:"types,omitempty"`
	// contains filtered or unexported fields
}

func (*ListTypesResponse) Descriptor deprecated added in v0.22.0

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

Deprecated: Use ListTypesResponse.ProtoReflect.Descriptor instead.

func (*ListTypesResponse) GetTypes added in v0.22.0

func (x *ListTypesResponse) GetTypes() []string

func (*ListTypesResponse) ProtoMessage added in v0.22.0

func (*ListTypesResponse) ProtoMessage()

func (*ListTypesResponse) ProtoReflect added in v0.22.0

func (x *ListTypesResponse) ProtoReflect() protoreflect.Message

func (*ListTypesResponse) Reset added in v0.22.0

func (x *ListTypesResponse) Reset()

func (*ListTypesResponse) String added in v0.22.0

func (x *ListTypesResponse) String() string

type Options added in v0.14.0

type Options struct {

	// capacity sets a maximum size for the given type. Once the capacity is
	// reached the oldest records will be removed.
	Capacity *uint64 `protobuf:"varint,1,opt,name=capacity,proto3,oneof" json:"capacity,omitempty"`
	// contains filtered or unexported fields
}

Options are the options for a type stored in the databroker.

func (*Options) Descriptor deprecated added in v0.14.0

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

Deprecated: Use Options.ProtoReflect.Descriptor instead.

func (*Options) GetCapacity added in v0.14.0

func (x *Options) GetCapacity() uint64

func (*Options) ProtoMessage added in v0.14.0

func (*Options) ProtoMessage()

func (*Options) ProtoReflect added in v0.14.0

func (x *Options) ProtoReflect() protoreflect.Message

func (*Options) Reset added in v0.14.0

func (x *Options) Reset()

func (*Options) String added in v0.14.0

func (x *Options) String() string

type PatchRequest added in v0.24.0

type PatchRequest struct {
	Records   []*Record              `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
	FieldMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=field_mask,json=fieldMask,proto3" json:"field_mask,omitempty"`
	// contains filtered or unexported fields
}

func (*PatchRequest) Descriptor deprecated added in v0.24.0

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

Deprecated: Use PatchRequest.ProtoReflect.Descriptor instead.

func (*PatchRequest) GetFieldMask added in v0.24.0

func (x *PatchRequest) GetFieldMask() *fieldmaskpb.FieldMask

func (*PatchRequest) GetRecords added in v0.24.0

func (x *PatchRequest) GetRecords() []*Record

func (*PatchRequest) ProtoMessage added in v0.24.0

func (*PatchRequest) ProtoMessage()

func (*PatchRequest) ProtoReflect added in v0.24.0

func (x *PatchRequest) ProtoReflect() protoreflect.Message

func (*PatchRequest) Reset added in v0.24.0

func (x *PatchRequest) Reset()

func (*PatchRequest) String added in v0.24.0

func (x *PatchRequest) String() string

type PatchResponse added in v0.24.0

type PatchResponse struct {
	ServerVersion uint64    `protobuf:"varint,1,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"`
	Records       []*Record `protobuf:"bytes,2,rep,name=records,proto3" json:"records,omitempty"`
	// contains filtered or unexported fields
}

func (*PatchResponse) Descriptor deprecated added in v0.24.0

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

Deprecated: Use PatchResponse.ProtoReflect.Descriptor instead.

func (*PatchResponse) GetRecord added in v0.24.0

func (x *PatchResponse) GetRecord() *Record

GetRecord gets the first record, or nil if there are none.

func (*PatchResponse) GetRecords added in v0.24.0

func (x *PatchResponse) GetRecords() []*Record

func (*PatchResponse) GetServerVersion added in v0.24.0

func (x *PatchResponse) GetServerVersion() uint64

func (*PatchResponse) ProtoMessage added in v0.24.0

func (*PatchResponse) ProtoMessage()

func (*PatchResponse) ProtoReflect added in v0.24.0

func (x *PatchResponse) ProtoReflect() protoreflect.Message

func (*PatchResponse) Reset added in v0.24.0

func (x *PatchResponse) Reset()

func (*PatchResponse) String added in v0.24.0

func (x *PatchResponse) String() string

type PutRequest added in v0.14.0

type PutRequest struct {
	Records []*Record `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
	// contains filtered or unexported fields
}

func OptimumPutRequestsFromRecords added in v0.17.3

func OptimumPutRequestsFromRecords(records []*Record) []*PutRequest

OptimumPutRequestsFromRecords creates one or more PutRequests from a slice of records. If the size of the request exceeds the max message size it will be split in half recursively until the requests are less than or equal to the max message size.

func (*PutRequest) Descriptor deprecated added in v0.14.0

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

Deprecated: Use PutRequest.ProtoReflect.Descriptor instead.

func (*PutRequest) GetRecord added in v0.14.0

func (x *PutRequest) GetRecord() *Record

GetRecord gets the first record, or nil if there are none.

func (*PutRequest) GetRecords added in v0.17.3

func (x *PutRequest) GetRecords() []*Record

func (*PutRequest) ProtoMessage added in v0.14.0

func (*PutRequest) ProtoMessage()

func (*PutRequest) ProtoReflect added in v0.14.0

func (x *PutRequest) ProtoReflect() protoreflect.Message

func (*PutRequest) Reset added in v0.14.0

func (x *PutRequest) Reset()

func (*PutRequest) String added in v0.14.0

func (x *PutRequest) String() string

type PutResponse added in v0.14.0

type PutResponse struct {
	ServerVersion uint64    `protobuf:"varint,1,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"`
	Records       []*Record `protobuf:"bytes,2,rep,name=records,proto3" json:"records,omitempty"`
	// contains filtered or unexported fields
}

func Put added in v0.17.0

func Put(ctx context.Context, client DataBrokerServiceClient, objects ...recordObject) (*PutResponse, error)

Put puts a record into the databroker.

func (*PutResponse) Descriptor deprecated added in v0.14.0

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

Deprecated: Use PutResponse.ProtoReflect.Descriptor instead.

func (*PutResponse) GetRecord added in v0.14.0

func (x *PutResponse) GetRecord() *Record

GetRecord gets the first record, or nil if there are none.

func (*PutResponse) GetRecords added in v0.17.3

func (x *PutResponse) GetRecords() []*Record

func (*PutResponse) GetServerVersion added in v0.14.0

func (x *PutResponse) GetServerVersion() uint64

func (*PutResponse) ProtoMessage added in v0.14.0

func (*PutResponse) ProtoMessage()

func (*PutResponse) ProtoReflect added in v0.14.0

func (x *PutResponse) ProtoReflect() protoreflect.Message

func (*PutResponse) Reset added in v0.14.0

func (x *PutResponse) Reset()

func (*PutResponse) String added in v0.14.0

func (x *PutResponse) String() string

type QueryRequest added in v0.11.0

type QueryRequest struct {
	Type   string           `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Query  string           `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty"`
	Offset int64            `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"`
	Limit  int64            `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"`
	Filter *structpb.Struct `protobuf:"bytes,5,opt,name=filter,proto3" json:"filter,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryRequest) Descriptor deprecated added in v0.11.0

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

Deprecated: Use QueryRequest.ProtoReflect.Descriptor instead.

func (*QueryRequest) GetFilter added in v0.18.0

func (x *QueryRequest) GetFilter() *structpb.Struct

func (*QueryRequest) GetLimit added in v0.11.0

func (x *QueryRequest) GetLimit() int64

func (*QueryRequest) GetOffset added in v0.11.0

func (x *QueryRequest) GetOffset() int64

func (*QueryRequest) GetQuery added in v0.11.0

func (x *QueryRequest) GetQuery() string

func (*QueryRequest) GetType added in v0.11.0

func (x *QueryRequest) GetType() string

func (*QueryRequest) ProtoMessage added in v0.11.0

func (*QueryRequest) ProtoMessage()

func (*QueryRequest) ProtoReflect added in v0.11.0

func (x *QueryRequest) ProtoReflect() protoreflect.Message

func (*QueryRequest) Reset added in v0.11.0

func (x *QueryRequest) Reset()

func (*QueryRequest) SetFilterByID added in v0.18.0

func (x *QueryRequest) SetFilterByID(id string)

SetFilterByID sets the filter to an id.

func (*QueryRequest) SetFilterByIDOrIndex added in v0.18.0

func (x *QueryRequest) SetFilterByIDOrIndex(idOrIndex string)

SetFilterByIDOrIndex sets the filter to an id or an index.

func (*QueryRequest) String added in v0.11.0

func (x *QueryRequest) String() string

type QueryResponse added in v0.11.0

type QueryResponse struct {
	Records       []*Record `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"`
	TotalCount    int64     `protobuf:"varint,2,opt,name=total_count,json=totalCount,proto3" json:"total_count,omitempty"`
	ServerVersion uint64    `protobuf:"varint,3,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"`
	RecordVersion uint64    `protobuf:"varint,4,opt,name=record_version,json=recordVersion,proto3" json:"record_version,omitempty"`
	// contains filtered or unexported fields
}

func (*QueryResponse) Descriptor deprecated added in v0.11.0

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

Deprecated: Use QueryResponse.ProtoReflect.Descriptor instead.

func (*QueryResponse) GetRecordVersion added in v0.18.0

func (x *QueryResponse) GetRecordVersion() uint64

func (*QueryResponse) GetRecords added in v0.11.0

func (x *QueryResponse) GetRecords() []*Record

func (*QueryResponse) GetServerVersion added in v0.18.0

func (x *QueryResponse) GetServerVersion() uint64

func (*QueryResponse) GetTotalCount added in v0.11.0

func (x *QueryResponse) GetTotalCount() int64

func (*QueryResponse) ProtoMessage added in v0.11.0

func (*QueryResponse) ProtoMessage()

func (*QueryResponse) ProtoReflect added in v0.11.0

func (x *QueryResponse) ProtoReflect() protoreflect.Message

func (*QueryResponse) Reset added in v0.11.0

func (x *QueryResponse) Reset()

func (*QueryResponse) String added in v0.11.0

func (x *QueryResponse) String() string

type Reconciler added in v0.24.0

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

Reconciler reconciles the target and current record sets with the databroker.

func NewReconciler added in v0.24.0

func NewReconciler(

	name string,
	client DataBrokerServiceClient,
	currentStateBuilder StateBuilderFn,
	targetStateBuilder StateBuilderFn,
	setCurrentState func([]*Record),
	cmpFn RecordCompareFn,
	opts ...ReconcilerOption,
) *Reconciler

NewReconciler creates a new reconciler

func (*Reconciler) GetDataBrokerServiceClient added in v0.24.0

func (r *Reconciler) GetDataBrokerServiceClient() DataBrokerServiceClient

GetDataBrokerServiceClient implements the LeaseHandler interface.

func (*Reconciler) Reconcile added in v0.25.0

func (r *Reconciler) Reconcile(ctx context.Context) error

Reconcile brings databroker state in line with the target state.

func (*Reconciler) Run added in v0.24.0

func (r *Reconciler) Run(ctx context.Context) error

Run runs the reconciler

func (*Reconciler) RunLeased added in v0.24.0

func (r *Reconciler) RunLeased(ctx context.Context) error

RunLeased implements the LeaseHandler interface.

func (*Reconciler) TriggerSync added in v0.24.0

func (r *Reconciler) TriggerSync()

TriggerSync triggers a sync

type ReconcilerOption added in v0.24.0

type ReconcilerOption func(*reconcilerConfig)

ReconcilerOption is an option for a reconciler.

func WithInterval added in v0.24.0

func WithInterval(interval time.Duration) ReconcilerOption

WithInterval sets the interval for the reconciler.

type Record

type Record struct {
	Version    uint64                 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	Type       string                 `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	Id         string                 `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`
	Data       *anypb.Any             `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
	ModifiedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=modified_at,json=modifiedAt,proto3" json:"modified_at,omitempty"`
	DeletedAt  *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=deleted_at,json=deletedAt,proto3" json:"deleted_at,omitempty"`
	// contains filtered or unexported fields
}

func ApplyOffsetAndLimit added in v0.11.0

func ApplyOffsetAndLimit(all []*Record, offset, limit int) (records []*Record, totalCount int)

ApplyOffsetAndLimit applies the offset and limit to the list of records.

func GetChangeSet added in v0.24.0

func GetChangeSet(current, target RecordSetBundle, cmpFn RecordCompareFn) []*Record

GetChangeSet returns list of changes between the current and target record sets, that may be applied to the databroker to bring it to the target state.

func InitialSync added in v0.11.0

func InitialSync(
	ctx context.Context,
	client DataBrokerServiceClient,
	req *SyncLatestRequest,
) (records []*Record, recordVersion, serverVersion uint64, err error)

InitialSync performs a sync latest and then returns all the results.

func NewRecord added in v0.17.0

func NewRecord(object recordObject) *Record

NewRecord creates a new Record.

func (*Record) Descriptor deprecated

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

Deprecated: Use Record.ProtoReflect.Descriptor instead.

func (*Record) GetData

func (x *Record) GetData() *anypb.Any

func (*Record) GetDeletedAt

func (x *Record) GetDeletedAt() *timestamppb.Timestamp

func (*Record) GetId

func (x *Record) GetId() string

func (*Record) GetModifiedAt

func (x *Record) GetModifiedAt() *timestamppb.Timestamp

func (*Record) GetType

func (x *Record) GetType() string

func (*Record) GetVersion

func (x *Record) GetVersion() uint64

func (*Record) MarshalJSON added in v0.24.0

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

MarshalJSON marshals the record to JSON.

func (*Record) ProtoMessage

func (*Record) ProtoMessage()

func (*Record) ProtoReflect

func (x *Record) ProtoReflect() protoreflect.Message

func (*Record) Reset

func (x *Record) Reset()

func (*Record) String

func (x *Record) String() string

func (*Record) UnmarshalJSON added in v0.24.0

func (r *Record) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the record from JSON.

type RecordCompareFn added in v0.24.0

type RecordCompareFn func(record1, record2 *Record) bool

RecordCompareFn is a function that compares two records.

type RecordSet added in v0.24.0

type RecordSet map[string]*Record

RecordSet is an index of databroker records by their id.

func (RecordSet) Flatten added in v0.24.0

func (rs RecordSet) Flatten() []*Record

Flatten returns all records in the set.

func (RecordSet) GetAdded added in v0.24.0

func (rs RecordSet) GetAdded(other RecordSet) RecordSet

GetAdded returns the records that are in other but not in rs.

func (RecordSet) GetModified added in v0.24.0

func (rs RecordSet) GetModified(other RecordSet, cmpFn RecordCompareFn) RecordSet

GetModified returns the records that are in both rs and other but have different data. by comparing the protobuf bytes of the payload.

func (RecordSet) GetRemoved added in v0.24.0

func (rs RecordSet) GetRemoved(other RecordSet) RecordSet

GetRemoved returns the records that are in rs but not in other.

type RecordSetBundle added in v0.24.0

type RecordSetBundle map[string]RecordSet

RecordSetBundle is an index of databroker records by type

func (RecordSetBundle) Add added in v0.24.0

func (rsb RecordSetBundle) Add(record *Record)

Add adds a record to the bundle.

func (RecordSetBundle) Flatten added in v0.24.0

func (rsb RecordSetBundle) Flatten() []*Record

Flatten returns all records in the bundle.

func (RecordSetBundle) Get added in v0.24.0

func (rsb RecordSetBundle) Get(typeName, id string) (record *Record, ok bool)

Get returns a record by type and id.

func (RecordSetBundle) GetAdded added in v0.24.0

func (rsb RecordSetBundle) GetAdded(other RecordSetBundle) RecordSetBundle

GetAdded returns the records that are in other but not in rsb.

func (RecordSetBundle) GetModified added in v0.24.0

func (rsb RecordSetBundle) GetModified(other RecordSetBundle, cmpFn RecordCompareFn) RecordSetBundle

GetModified returns the records that are in both rs and other but have different data.

func (RecordSetBundle) GetRemoved added in v0.24.0

func (rsb RecordSetBundle) GetRemoved(other RecordSetBundle) RecordSetBundle

GetRemoved returns the records that are in rs but not in other.

func (RecordSetBundle) RecordTypes added in v0.24.0

func (rsb RecordSetBundle) RecordTypes() []string

RecordTypes returns the types of records in the bundle.

type ReleaseLeaseRequest added in v0.15.0

type ReleaseLeaseRequest struct {
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Id   string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*ReleaseLeaseRequest) Descriptor deprecated added in v0.15.0

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

Deprecated: Use ReleaseLeaseRequest.ProtoReflect.Descriptor instead.

func (*ReleaseLeaseRequest) GetId added in v0.15.0

func (x *ReleaseLeaseRequest) GetId() string

func (*ReleaseLeaseRequest) GetName added in v0.15.0

func (x *ReleaseLeaseRequest) GetName() string

func (*ReleaseLeaseRequest) ProtoMessage added in v0.15.0

func (*ReleaseLeaseRequest) ProtoMessage()

func (*ReleaseLeaseRequest) ProtoReflect added in v0.15.0

func (x *ReleaseLeaseRequest) ProtoReflect() protoreflect.Message

func (*ReleaseLeaseRequest) Reset added in v0.15.0

func (x *ReleaseLeaseRequest) Reset()

func (*ReleaseLeaseRequest) String added in v0.15.0

func (x *ReleaseLeaseRequest) String() string

type RenewLeaseRequest added in v0.15.0

type RenewLeaseRequest struct {
	Name     string               `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Id       string               `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	Duration *durationpb.Duration `protobuf:"bytes,3,opt,name=duration,proto3" json:"duration,omitempty"`
	// contains filtered or unexported fields
}

func (*RenewLeaseRequest) Descriptor deprecated added in v0.15.0

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

Deprecated: Use RenewLeaseRequest.ProtoReflect.Descriptor instead.

func (*RenewLeaseRequest) GetDuration added in v0.15.0

func (x *RenewLeaseRequest) GetDuration() *durationpb.Duration

func (*RenewLeaseRequest) GetId added in v0.15.0

func (x *RenewLeaseRequest) GetId() string

func (*RenewLeaseRequest) GetName added in v0.15.0

func (x *RenewLeaseRequest) GetName() string

func (*RenewLeaseRequest) ProtoMessage added in v0.15.0

func (*RenewLeaseRequest) ProtoMessage()

func (*RenewLeaseRequest) ProtoReflect added in v0.15.0

func (x *RenewLeaseRequest) ProtoReflect() protoreflect.Message

func (*RenewLeaseRequest) Reset added in v0.15.0

func (x *RenewLeaseRequest) Reset()

func (*RenewLeaseRequest) String added in v0.15.0

func (x *RenewLeaseRequest) String() string

type SetOptionsRequest added in v0.14.0

type SetOptionsRequest struct {
	Type    string   `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Options *Options `protobuf:"bytes,2,opt,name=options,proto3" json:"options,omitempty"`
	// contains filtered or unexported fields
}

func (*SetOptionsRequest) Descriptor deprecated added in v0.14.0

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

Deprecated: Use SetOptionsRequest.ProtoReflect.Descriptor instead.

func (*SetOptionsRequest) GetOptions added in v0.14.0

func (x *SetOptionsRequest) GetOptions() *Options

func (*SetOptionsRequest) GetType added in v0.14.0

func (x *SetOptionsRequest) GetType() string

func (*SetOptionsRequest) ProtoMessage added in v0.14.0

func (*SetOptionsRequest) ProtoMessage()

func (*SetOptionsRequest) ProtoReflect added in v0.14.0

func (x *SetOptionsRequest) ProtoReflect() protoreflect.Message

func (*SetOptionsRequest) Reset added in v0.14.0

func (x *SetOptionsRequest) Reset()

func (*SetOptionsRequest) String added in v0.14.0

func (x *SetOptionsRequest) String() string

type SetOptionsResponse added in v0.14.0

type SetOptionsResponse struct {
	Options *Options `protobuf:"bytes,1,opt,name=options,proto3" json:"options,omitempty"`
	// contains filtered or unexported fields
}

func (*SetOptionsResponse) Descriptor deprecated added in v0.14.0

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

Deprecated: Use SetOptionsResponse.ProtoReflect.Descriptor instead.

func (*SetOptionsResponse) GetOptions added in v0.14.0

func (x *SetOptionsResponse) GetOptions() *Options

func (*SetOptionsResponse) ProtoMessage added in v0.14.0

func (*SetOptionsResponse) ProtoMessage()

func (*SetOptionsResponse) ProtoReflect added in v0.14.0

func (x *SetOptionsResponse) ProtoReflect() protoreflect.Message

func (*SetOptionsResponse) Reset added in v0.14.0

func (x *SetOptionsResponse) Reset()

func (*SetOptionsResponse) String added in v0.14.0

func (x *SetOptionsResponse) String() string

type StateBuilderFn added in v0.24.0

type StateBuilderFn func(ctx context.Context) (RecordSetBundle, error)

StateBuilderFn is a function that builds a record set bundle

type SyncLatestRequest added in v0.14.0

type SyncLatestRequest struct {
	Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	// contains filtered or unexported fields
}

func (*SyncLatestRequest) Descriptor deprecated added in v0.14.0

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

Deprecated: Use SyncLatestRequest.ProtoReflect.Descriptor instead.

func (*SyncLatestRequest) GetType added in v0.14.0

func (x *SyncLatestRequest) GetType() string

func (*SyncLatestRequest) ProtoMessage added in v0.14.0

func (*SyncLatestRequest) ProtoMessage()

func (*SyncLatestRequest) ProtoReflect added in v0.14.0

func (x *SyncLatestRequest) ProtoReflect() protoreflect.Message

func (*SyncLatestRequest) Reset added in v0.14.0

func (x *SyncLatestRequest) Reset()

func (*SyncLatestRequest) String added in v0.14.0

func (x *SyncLatestRequest) String() string

type SyncLatestResponse added in v0.14.0

type SyncLatestResponse struct {

	// Types that are assignable to Response:
	//
	//	*SyncLatestResponse_Record
	//	*SyncLatestResponse_Versions
	Response isSyncLatestResponse_Response `protobuf_oneof:"response"`
	// contains filtered or unexported fields
}

func (*SyncLatestResponse) Descriptor deprecated added in v0.14.0

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

Deprecated: Use SyncLatestResponse.ProtoReflect.Descriptor instead.

func (*SyncLatestResponse) GetRecord added in v0.14.0

func (x *SyncLatestResponse) GetRecord() *Record

func (*SyncLatestResponse) GetResponse added in v0.14.0

func (m *SyncLatestResponse) GetResponse() isSyncLatestResponse_Response

func (*SyncLatestResponse) GetVersions added in v0.14.0

func (x *SyncLatestResponse) GetVersions() *Versions

func (*SyncLatestResponse) ProtoMessage added in v0.14.0

func (*SyncLatestResponse) ProtoMessage()

func (*SyncLatestResponse) ProtoReflect added in v0.14.0

func (x *SyncLatestResponse) ProtoReflect() protoreflect.Message

func (*SyncLatestResponse) Reset added in v0.14.0

func (x *SyncLatestResponse) Reset()

func (*SyncLatestResponse) String added in v0.14.0

func (x *SyncLatestResponse) String() string

type SyncLatestResponse_Record added in v0.14.0

type SyncLatestResponse_Record struct {
	Record *Record `protobuf:"bytes,1,opt,name=record,proto3,oneof"`
}

type SyncLatestResponse_Versions added in v0.14.0

type SyncLatestResponse_Versions struct {
	Versions *Versions `protobuf:"bytes,2,opt,name=versions,proto3,oneof"`
}

type SyncRequest

type SyncRequest struct {
	ServerVersion uint64 `protobuf:"varint,1,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"`
	RecordVersion uint64 `protobuf:"varint,2,opt,name=record_version,json=recordVersion,proto3" json:"record_version,omitempty"`
	Type          string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
	// contains filtered or unexported fields
}

func (*SyncRequest) Descriptor deprecated

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

Deprecated: Use SyncRequest.ProtoReflect.Descriptor instead.

func (*SyncRequest) GetRecordVersion

func (x *SyncRequest) GetRecordVersion() uint64

func (*SyncRequest) GetServerVersion

func (x *SyncRequest) GetServerVersion() uint64

func (*SyncRequest) GetType

func (x *SyncRequest) GetType() string

func (*SyncRequest) ProtoMessage

func (*SyncRequest) ProtoMessage()

func (*SyncRequest) ProtoReflect

func (x *SyncRequest) ProtoReflect() protoreflect.Message

func (*SyncRequest) Reset

func (x *SyncRequest) Reset()

func (*SyncRequest) String

func (x *SyncRequest) String() string

type SyncResponse

type SyncResponse struct {
	Record *Record `protobuf:"bytes,1,opt,name=record,proto3" json:"record,omitempty"`
	// contains filtered or unexported fields
}

func (*SyncResponse) Descriptor deprecated

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

Deprecated: Use SyncResponse.ProtoReflect.Descriptor instead.

func (*SyncResponse) GetRecord added in v0.14.0

func (x *SyncResponse) GetRecord() *Record

func (*SyncResponse) ProtoMessage

func (*SyncResponse) ProtoMessage()

func (*SyncResponse) ProtoReflect

func (x *SyncResponse) ProtoReflect() protoreflect.Message

func (*SyncResponse) Reset

func (x *SyncResponse) Reset()

func (*SyncResponse) String

func (x *SyncResponse) String() string

type Syncer added in v0.14.0

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

A Syncer is a helper type for working with Sync and SyncLatest. It will make a call to SyncLatest to retrieve the latest version of the data, then begin syncing with a call to Sync. If the server version changes `ClearRecords` will be called and the process will start over.

func NewSyncer added in v0.14.0

func NewSyncer(id string, handler SyncerHandler, options ...SyncerOption) *Syncer

NewSyncer creates a new Syncer.

func (*Syncer) Close added in v0.14.0

func (syncer *Syncer) Close() error

Close closes the Syncer.

func (*Syncer) Run added in v0.14.0

func (syncer *Syncer) Run(ctx context.Context) error

Run runs the Syncer.

type SyncerHandler added in v0.14.0

type SyncerHandler interface {
	GetDataBrokerServiceClient() DataBrokerServiceClient
	ClearRecords(ctx context.Context)
	UpdateRecords(ctx context.Context, serverVersion uint64, records []*Record)
}

A SyncerHandler receives sync events from the Syncer.

type SyncerOption added in v0.14.0

type SyncerOption func(cfg *syncerConfig)

A SyncerOption customizes the syncer configuration.

func WithFastForward added in v0.15.5

func WithFastForward() SyncerOption

WithFastForward in case updates are coming faster then Update can process them, will skip older records to maintain an update rate. Use for entries that represent a full state snapshot i.e. Config

func WithTypeURL added in v0.14.0

func WithTypeURL(typeURL string) SyncerOption

WithTypeURL restricts the sync'd results to the given type.

type UnimplementedDataBrokerServiceServer

type UnimplementedDataBrokerServiceServer struct {
}

UnimplementedDataBrokerServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedDataBrokerServiceServer) AcquireLease added in v0.15.0

func (*UnimplementedDataBrokerServiceServer) Get

func (*UnimplementedDataBrokerServiceServer) ListTypes added in v0.22.0

func (*UnimplementedDataBrokerServiceServer) Patch added in v0.24.0

func (*UnimplementedDataBrokerServiceServer) Put added in v0.14.0

func (*UnimplementedDataBrokerServiceServer) Query added in v0.11.0

func (*UnimplementedDataBrokerServiceServer) ReleaseLease added in v0.15.0

func (*UnimplementedDataBrokerServiceServer) RenewLease added in v0.15.0

func (*UnimplementedDataBrokerServiceServer) SetOptions added in v0.14.0

func (*UnimplementedDataBrokerServiceServer) Sync

func (*UnimplementedDataBrokerServiceServer) SyncLatest added in v0.14.0

type Versions added in v0.14.0

type Versions struct {

	// the server version indicates the version of the server storing the data
	ServerVersion       uint64 `protobuf:"varint,1,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"`
	LatestRecordVersion uint64 `protobuf:"varint,2,opt,name=latest_record_version,json=latestRecordVersion,proto3" json:"latest_record_version,omitempty"`
	// contains filtered or unexported fields
}

func (*Versions) Descriptor deprecated added in v0.14.0

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

Deprecated: Use Versions.ProtoReflect.Descriptor instead.

func (*Versions) GetLatestRecordVersion added in v0.14.0

func (x *Versions) GetLatestRecordVersion() uint64

func (*Versions) GetServerVersion added in v0.14.0

func (x *Versions) GetServerVersion() uint64

func (*Versions) ProtoMessage added in v0.14.0

func (*Versions) ProtoMessage()

func (*Versions) ProtoReflect added in v0.14.0

func (x *Versions) ProtoReflect() protoreflect.Message

func (*Versions) Reset added in v0.14.0

func (x *Versions) Reset()

func (*Versions) String added in v0.14.0

func (x *Versions) String() string

Directories

Path Synopsis
Package mock_databroker is a generated GoMock package.
Package mock_databroker is a generated GoMock package.

Jump to

Keyboard shortcuts

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