@@ -1631,6 +1631,7 @@ class Server::WorkerService final: public Service,
1631
1631
kj::Maybe<kj::Own<SqliteDatabase::Vfs>> actorStorage;
1632
1632
AlarmScheduler& alarmScheduler;
1633
1633
kj::Array<kj::Own<Service>> tails;
1634
+ kj::Array<kj::Own<Service>> streamingTails;
1634
1635
};
1635
1636
using LinkCallback = kj::Function<LinkedIoChannels(WorkerService&)>;
1636
1637
using AbortActorsCallback = kj::Function<void ()>;
@@ -1760,25 +1761,20 @@ class Server::WorkerService final: public Service,
1760
1761
1761
1762
kj::Array<kj::Own<WorkerInterface>> legacyTailWorkers = nullptr ;
1762
1763
kj::Array<kj::Own<WorkerInterface>> streamingTailWorkers = nullptr ;
1763
- // If streaming tail workers is enabled, then we will initialize two lists:
1764
- // one with services that only export the tail or trace handler (legacy tail
1765
- // workers) and one that exports the tailStream handler. We'll check tailStreams
1766
- // first.
1764
+ legacyTailWorkers = KJ_MAP (service, channels.tails ) -> kj::Own<WorkerInterface> {
1765
+ // Caution here... if the tail worker ends up have a circular dependency
1766
+ // on the worker we'll end up with an infinite loop trying to initialize.
1767
+ // We can test this directly but it's more difficult to test indirect
1768
+ // loops (dependency of dependency, etc). Here we're just going to keep
1769
+ // it simple and just check the direct dependency.
1770
+ // If service refers to an EntrypointService, we need to compare with the underlying
1771
+ // WorkerService to match this.
1772
+ KJ_ASSERT (service->service () != this , " A worker currently cannot log to itself" );
1773
+ return service->startRequest ({});
1774
+ };
1775
+
1767
1776
if (util::Autogate::isEnabled (util::AutogateKey::STREAMING_TAIL_WORKERS)) {
1768
- kj::Vector<kj::Own<WorkerInterface>> legacyList;
1769
- kj::Vector<kj::Own<WorkerInterface>> streamingList;
1770
- for (auto & service: channels.tails ) {
1771
- KJ_ASSERT (service->service () != this , " A worker currently cannot log to itself" );
1772
- if (service->hasHandler (" tailStream" _kj)) {
1773
- streamingList.add (service->startRequest ({}));
1774
- } else if (service->hasHandler (" tail" ) || service->hasHandler (" trace" )) {
1775
- legacyList.add (service->startRequest ({}));
1776
- }
1777
- }
1778
- legacyTailWorkers = legacyList.releaseAsArray ();
1779
- streamingTailWorkers = streamingList.releaseAsArray ();
1780
- } else {
1781
- legacyTailWorkers = KJ_MAP (service, channels.tails ) -> kj::Own<WorkerInterface> {
1777
+ streamingTailWorkers = KJ_MAP (service, channels.streamingTails ) -> kj::Own<WorkerInterface> {
1782
1778
// Caution here... if the tail worker ends up have a circular dependency
1783
1779
// on the worker we'll end up with an infinite loop trying to initialize.
1784
1780
// We can test this directly but it's more difficult to test indirect
@@ -3475,6 +3471,10 @@ kj::Own<Server::Service> Server::makeWorker(kj::StringPtr name,
3475
3471
return lookupService (tail, kj::str (" Worker \" " , name, " \" 's tails" ));
3476
3472
};
3477
3473
3474
+ result.streamingTails = KJ_MAP (streamingTails, conf.getStreamingTails ()) {
3475
+ return lookupService (streamingTails, kj::str (" Worker \" " , name, " \" 's streaming tails" ));
3476
+ };
3477
+
3478
3478
return result;
3479
3479
};
3480
3480
0 commit comments