@@ -26,14 +26,12 @@ internal class CapPublisher : ICapPublisher
2626 private readonly ISnowflakeId _snowflakeId ;
2727 private readonly IDispatcher _dispatcher ;
2828 private readonly IDataStorage _storage ;
29- private readonly IBootstrapper _bootstrapper ;
3029
3130 private readonly AsyncLocal < CapTransactionHolder > _asyncLocal ;
3231
3332 public CapPublisher ( IServiceProvider service )
3433 {
3534 ServiceProvider = service ;
36- _bootstrapper = service . GetRequiredService < IBootstrapper > ( ) ;
3735 _dispatcher = service . GetRequiredService < IDispatcher > ( ) ;
3836 _storage = service . GetRequiredService < IDataStorage > ( ) ;
3937 _capOptions = service . GetRequiredService < IOptions < CapOptions > > ( ) . Value ;
@@ -43,8 +41,8 @@ public CapPublisher(IServiceProvider service)
4341
4442 public IServiceProvider ServiceProvider { get ; }
4543
46- public ICapTransaction ? Transaction {
47-
44+ public ICapTransaction ? Transaction
45+ {
4846 get => _asyncLocal . Value ? . Transaction ;
4947 set
5048 {
@@ -114,11 +112,6 @@ public void PublishDelay<T>(TimeSpan delayTime, string name, T? value, string? c
114112 private async Task PublishInternalAsync < T > ( string name , T ? value , IDictionary < string , string ? > headers , TimeSpan ? delayTime = null ,
115113 CancellationToken cancellationToken = default )
116114 {
117- if ( ! _bootstrapper . IsStarted )
118- {
119- throw new InvalidOperationException ( "CAP has not been started!" ) ;
120- }
121-
122115 if ( string . IsNullOrEmpty ( name ) ) throw new ArgumentNullException ( nameof ( name ) ) ;
123116
124117 if ( ! string . IsNullOrEmpty ( _capOptions . TopicNamePrefix ) ) name = $ "{ _capOptions . TopicNamePrefix } .{ name } ";
@@ -176,8 +169,7 @@ private async Task PublishInternalAsync<T>(string name, T? value, IDictionary<st
176169 {
177170 var transaction = ( CapTransactionBase ) Transaction ;
178171
179- var mediumMessage = await _storage . StoreMessageAsync ( name , message , transaction . DbTransaction )
180- . ConfigureAwait ( false ) ;
172+ var mediumMessage = await _storage . StoreMessageAsync ( name , message , transaction . DbTransaction ) . ConfigureAwait ( false ) ;
181173
182174 TracingAfter ( tracingTimestamp , message ) ;
183175
0 commit comments