common

package
v0.0.0-...-1b33b2a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangefeedFlowController

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

ChangefeedFlowController provides a convenient interface to control the memory consumption of a per changefeed event stream

func NewChangefeedFlowController

func NewChangefeedFlowController(quota uint64) *ChangefeedFlowController

NewChangefeedFlowController creates a new ChangefeedFlowController

func (*ChangefeedFlowController) Abort

func (c *ChangefeedFlowController) Abort()

Abort interrupts any ongoing Consume call

func (*ChangefeedFlowController) Consume

func (c *ChangefeedFlowController) Consume(commitTs uint64, size uint64, blockCallBack func() error) error

Consume is called when an event has arrived for being processed by the sink. It will handle transaction boundaries automatically, and will not block intra-transaction.

func (*ChangefeedFlowController) GetConsumption

func (c *ChangefeedFlowController) GetConsumption() uint64

GetConsumption returns the current memory consumption

func (*ChangefeedFlowController) Release

func (c *ChangefeedFlowController) Release(resolvedTs uint64)

Release is called when all events committed before resolvedTs has been freed from memory.

type ChangefeedMemoryQuota

type ChangefeedMemoryQuota struct {
	Quota uint64 // should not be changed once intialized

	IsAborted uint32

	Consumed uint64
	// contains filtered or unexported fields
}

ChangefeedMemoryQuota is designed to curb the total memory consumption of processing the event streams in a chagnefeed. A higher-level controller more suitable for direct use by the processor is ChangefeedFlowController.

func NewChangefeedMemoryQuota

func NewChangefeedMemoryQuota(quota uint64) *ChangefeedMemoryQuota

NewChangefeedMemoryQuota creates a new ChangefeedMemoryQuota quota: max advised memory consumption in bytes.

func (*ChangefeedMemoryQuota) Abort

func (c *ChangefeedMemoryQuota) Abort()

Abort interrupts any ongoing ConsumeWithBlocking call

func (*ChangefeedMemoryQuota) ConsumeWithBlocking

func (c *ChangefeedMemoryQuota) ConsumeWithBlocking(nBytes uint64, blockCallBack func() error) error

ConsumeWithBlocking is called when a hard-limit is needed. The method will block until enough memory has been freed up by Release. blockCallBack will be called if the function will block. Should be used with care to prevent deadlock.

func (*ChangefeedMemoryQuota) ForceConsume

func (c *ChangefeedMemoryQuota) ForceConsume(nBytes uint64) error

ForceConsume is called when blocking is not acceptable and the limit can be violated for the sake of avoid deadlock. It merely records the increased memory consumption.

func (*ChangefeedMemoryQuota) GetConsumption

func (c *ChangefeedMemoryQuota) GetConsumption() uint64

GetConsumption returns the current memory consumption

func (*ChangefeedMemoryQuota) Release

func (c *ChangefeedMemoryQuota) Release(nBytes uint64)

Release is called when a chuck of memory is done being used.

Jump to

Keyboard shortcuts

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