Badgerati / Pode

Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
https://badgerati.github.io/Pode
MIT License
830 stars 92 forks source link

Experimental feature Pode State structure threadsafe #1350

Open mdaneri opened 2 months ago

mdaneri commented 2 months ago

Summary

This PR introduces a new experimental feature that modifies the $PodeContext.Server.State type from a standard hashtable to a threadsafe ConcurrentDictionary. This change aims to improve thread safety and simplify the manipulation of the state variable by removing the need to encapsulate operations within a scriptblock using Lock-PodeObject.

Changes

Benefits

Implementation Details

Enabling the Feature

There are two ways to enable this new experimental feature:

  1. Inside the server.psd1 file:

    @{
        Experimental = @{
            ConcurrentDictionaryState = $true 
        }
    }
  2. Pass the -Experimental parameter to Start-PodeServer:

    @{
        ConcurrentDictionaryState = $true 
    }