planlocks

package
v0.0.0-...-4799779 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package planlocks provides a mechanism to manage read-write locks for different plan IDs. This is useful for ensuring that only one goroutine is creating or modifying a plan at a time, while still allowing concurrent read access to plans that are not being modified.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

Group manages read-write locks for different plan IDs.

func New

func New(ctx context.Context) *Group

New creates a new Group for managing plan locks. There is a background goroutine that cleans up unused locks every minute. If the provided context is canceled, the cleanup goroutine will stop and the Group will no longer function.

func (*Group) Lock

func (g *Group) Lock(planID uuid.UUID)

Lock acquires a write lock for the given planID.

func (*Group) RLock

func (g *Group) RLock(planID uuid.UUID)

RLock acquires a read lock for the given planID.

func (*Group) RUnlock

func (g *Group) RUnlock(planID uuid.UUID)

RUnlock releases the read lock for the given planID.

func (*Group) Unlock

func (g *Group) Unlock(planID uuid.UUID)

Unlock releases the write lock for the given planID.

Jump to

Keyboard shortcuts

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