sfp - flxbl package manager
#flxblsfopsSlackGitHub
  • Overview
  • Getting Started
    • Pre-Requisites
    • Install sfp
    • Configure Your Project
    • Build & Install an Artifact
    • Congratulations!
    • Docker Images
      • sfp-pro
  • CONCEPTS
    • Overview
    • SF CLI vs. SFP
    • Domains
    • Packages
    • Supported package types
      • Unlocked Packages
      • Org-Dependent Unlocked Packages
      • Source Packages
      • Diff Package
      • Data Packages
    • Artifacts
    • Package vs Artifacts
    • Identifying types of a package
    • Dependency management
    • Transitive Dependency Resolution
    • Destructive Changes
  • configuring a project
    • Project structure
    • Setup Salesforce Org
    • Creating a package
    • Defining a domain
    • Release Config
  • BUILDING ARTIFACTS
    • Overview
    • Determining whether an artifact need to be built
    • Building a domain
    • Building an artifact for package individually
    • Limiting artifacts to be built
    • Controlling aspects of the build command
      • Ignoring packages from being built
      • Building a collection of packages together
      • Selective ignoring of components from being built
      • Use of multiple config file in build command
    • Configuring installation behaviour of a package
      • Always deploy a package
      • Skip Install on Certain Orgs
      • Optimized Installation
      • Pre/Post Deployment Script
      • Reconciling Profiles
      • PermissionSet Assignment
      • Updating Picklist
      • Entitlement Deployment Helper
      • Field History & Feed Tracking
      • Aliasfy Packages
        • Aliasfy Packages - Merge Mode
      • State management for Flows
  • Installing an artifact
    • Overview
    • Controlling Aspects of Installation
    • Applying attributes of an artifact
    • BuiltIn Deployment Helpers
      • PermissionSet Group Awaiter
  • publishing and fetching artifacts
    • Publish Artifact
    • Fetching Artifacts
  • Releasing artifacts
    • Overview
    • Release Definitions
    • Generating a release definition
    • Generating a changelog
  • Validating a change
    • Overview
    • Different types of validation
    • Limiting Validation by Domain
    • Controlling validation attributes of a package
      • Skip Testing
      • Skip Coverage Validation
      • Test Synchronously
  • Analysing a Project
    • Overview
    • Duplicate Check
  • Environment Management
    • Pools
      • Scratch Org Pools
        • Defining a pool
        • Setting up your Salesforce Org for Scratch Org Pools
        • Pool Operations
          • Preparing pools
            • Handling dependencies
          • List Scratch Orgs in a pool
          • Fetch a scratch org
          • Delete Pools
      • Sandbox Pools
        • Sandbox Pool Initialization
        • Fetch a Sandbox from Pool
        • Monitor Sandbox Pools
    • Review Environments
      • Commands
        • Fetch a Review Environment
        • Check Review Environment Status
        • Extend a Review Environment
        • Transition Review Environment Status
        • Unassign a Review Environment
      • Considerations
    • Sandbox
      • Create Sandbox
      • Delete Sandbox
      • List Sandbox
      • Login to Sandbox
      • Update Sandbox
  • Development
    • Development Environment
    • Pull Changes from your org
    • Push Changes to your org
    • Dependency Management
      • Expand Dependencies
      • Shrink Dependencies
      • Explain Dependencies
  • Running sfp as a server
    • Introduction
    • sfp-pro-server: Architecture Overview (Alpha)
      • Task Processing System
      • Authentication & Security Architecture
      • Authentication System: Deep Dive
      • Database Architecture
      • Network Architecture and Integration System
      • Integration Architecture: Building Extensions
    • Installing SFP Server
    • Initializing SFP server
  • Metrics
    • Available Metrics
    • Custom Metrics
    • Configuring Collectors
      • Datadog
      • Splunk
      • New Relic
      • StatsD
  • Helpers
    • Managing Shared Resources
  • Command Guide
    • Core
      • Build
      • Quickbuild
      • Publish
      • Install
      • Release
    • Advanced
      • Validate
      • Artifacts
      • Changelog
      • Impact
      • Pool
      • Metrics
      • Repo
    • Utilities
      • Apex Tests
      • Flow
      • Dependency
      • Profile
  • FAQs
    • Common Errors
      • Org Shapes
      • Troubleshooting Unlocked Packages Build Failure Due to Code Coverage
    • Common Questions
      • Email Templates Deployment: Classic vs Lightning
      • Dealing with Long Build Times in Salesforce
      • Standard ValueSets and unlocked packages
      • Common Issues encountered with aliasfied packages
      • API Version
      • Understanding alwaysDeploy and skipIfAlreadyInstalled in Deployment Pipelines
    • sfp versioning and upgrade Process
  • References
  • Legal
    • Terms of Service for sfp
    • Terms of Service for 'sfp-pro' Software
  • LLMs.txt
Powered by GitBook
On this page
  • Commands
  • 1. Request a lock on a resource
  • 2. Wait for a Lock
  • 3. Unlock a Resource
  • Usage Scenarios
  • Considerations

Was this helpful?

Edit on GitHub
Export as PDF
  1. Helpers

Managing Shared Resources

The commands are only available in sfp-pro (August 24 onwards). You also need an equivalent APP_ID & PRIVATE_KEY in your environment variable to access these commands.

sfp provides commands which allow you to coordinate access to shared resources across multiple processes or machines using a distributed locking mechanism. The locks are stored in a GitHub repository, and the commands provide an easy-to-use interface for acquiring, releasing, and waiting for locks.

Commands

1. Request a lock on a resource

Command:

$ sfp gh resource enqueue --repository owner/repo --resource resource-name --leasefor 1800

Description: This command is used to acquire a lock on a specific resource. It returns a ticket ID representing the lock.

Options:

  • --repository: Specifies the GitHub repository where the lock information will be stored. Defaults to the value of the GITHUB_REPOSITORY environment variable.

  • --resource: Specifies the name of the resource to be locked. Defaults to 'gh-vars'.

  • --leasefor: Specifies the lease duration for the lock in seconds. Defaults to 900 seconds (15 mins)

2. Wait for a Lock

Command:

$ sfp gh resource wait --repository owner/repo --resource resource-name --ticketid ticket-id --timeout 1800

Description: This command is used to wait for a lock to be acquired. It will block until the lock is successfully acquired or the specified timeout is reached.

Options:

  • --repository and --resource: Same as in the Lock command.

  • --ticketid: Specifies the ticket ID returned by the Lock command, representing the lock to wait for.

  • --timeout: Specifies the maximum time in seconds to wait for the lock. Defaults to 900 seconds (15 mins).

3. Unlock a Resource

Command:

$ sfp gh resource dequeue --repository owner/repo --resource resource-name --ticketid ticket-id

Description: This command is used to release a lock on a specific resource for the particular ticket

Options:

  • --repository and --resource: Same as in the Lock command.

  • --ticketid: Specifies the ticket ID associated with the lock to be released.

Usage Scenarios

  1. Exclusive Access to a Shared Resource:

    • Use the enqueue command to request a lock on a shared resource before accessing it.

    • Use the wait command to wait for the lock to be acquired before proceeding with the tasks.

    • After finishing the operations, use the dequeue command to release the lock, allowing other processes to access the resource.

  2. Coordinating Dependent Tasks:

    • Use the enqueue command to acquire locks on multiple resources required for a set of dependent tasks.

    • Use the wait command to wait for the locks to be acquired before proceeding with the tasks.

    • After completing the tasks, use the dequeue command to release the locks.

  3. Preventing Concurrent Modifications:

    • Use the enqueue command to acquire a lock before modifying a shared resource.

    • Use the wait command to wait for the lock to be acquired before proceeding with the tasks.

    • Perform the modifications while holding the lock to ensure exclusive access.

    • Use the dequeue command to release the lock once the modifications are complete.

Considerations

  • Choose a unique and descriptive name for the --resource option to avoid conflicts with other locks.

  • Specify an appropriate lease duration (--leasefor) based on the expected time required to perform the desired operations.

  • Always release locks using the dequeue command after finishing the operations to avoid holding locks unnecessarily.

  • Handle exceptions and errors appropriately when using the commands, such as retrying with a longer timeout or gracefully failing.

  • Be mindful of GitHub's API rate limits, especially when dealing with a high volume of lock requests.

By following these usage guidelines and consideations, you can effectively utilize the provided commands to coordinate access to shared resources and ensure proper synchronization across multiple processes or machines.

PreviousStatsDNextCore

Last updated 8 months ago

Was this helpful?