Skip to content

Commit

Permalink
Remove Hot Reload Hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Feb 27, 2025
1 parent 5c69f8a commit 345a466
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions src/HotChocolate/Core/src/Execution/RequestExecutorResolver.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Immutable;
using System.Reflection.Metadata;
using System.Threading.Channels;
using HotChocolate.Configuration;
using HotChocolate.Execution;
using HotChocolate.Execution.Caching;
using HotChocolate.Execution.Configuration;
using HotChocolate.Execution.Errors;
Expand All @@ -20,8 +18,6 @@
using Microsoft.Extensions.ObjectPool;
using static HotChocolate.Execution.ThrowHelper;

[assembly: MetadataUpdateHandler(typeof(RequestExecutorResolver.ApplicationUpdateHandler))]

namespace HotChocolate.Execution;

internal sealed partial class RequestExecutorResolver
Expand Down Expand Up @@ -61,10 +57,6 @@ public RequestExecutorResolver(
ConsumeExecutorEvictionsAsync(executorEvictionChannel.Reader, _cts.Token).FireAndForget();

_optionsMonitor.OnChange(EvictRequestExecutor);

// we register the schema eviction for application updates when hot reload is used.
// Whenever a hot reload update is triggered we will evict all executors.
ApplicationUpdateHandler.RegisterForApplicationUpdate(EvictAllRequestExecutors);
}

public IObservable<RequestExecutorEvent> Events => _events;
Expand Down Expand Up @@ -243,14 +235,6 @@ await CreateRequestExecutorAsync(schemaName, false, CancellationToken.None)
}
}

private void EvictAllRequestExecutors()
{
foreach (var key in _executors.Keys)
{
EvictRequestExecutor(key);
}
}

private static async Task RunEvictionEvents(RegisteredExecutor registeredExecutor)
{
try
Expand Down Expand Up @@ -777,32 +761,4 @@ private sealed class SchemaSetupInfo(

public IList<RequestCoreMiddleware> Pipeline { get; } = pipeline;
}

/// <summary>
/// A helper calls that receives hot reload update events from the runtime and triggers
/// reload of registered components.
/// </summary>
internal static class ApplicationUpdateHandler
{
private static readonly List<Action> _actions = [];

public static void RegisterForApplicationUpdate(Action action)
{
lock (_actions)
{
_actions.Add(action);
}
}

public static void UpdateApplication(Type[]? updatedTypes)
{
lock (_actions)
{
foreach (var action in _actions)
{
action();
}
}
}
}
}

0 comments on commit 345a466

Please sign in to comment.