@@ -26,14 +26,12 @@ internal class CapPublisher : ICapPublisher
26
26
private readonly ISnowflakeId _snowflakeId ;
27
27
private readonly IDispatcher _dispatcher ;
28
28
private readonly IDataStorage _storage ;
29
- private readonly IBootstrapper _bootstrapper ;
30
29
31
30
private readonly AsyncLocal < CapTransactionHolder > _asyncLocal ;
32
31
33
32
public CapPublisher ( IServiceProvider service )
34
33
{
35
34
ServiceProvider = service ;
36
- _bootstrapper = service . GetRequiredService < IBootstrapper > ( ) ;
37
35
_dispatcher = service . GetRequiredService < IDispatcher > ( ) ;
38
36
_storage = service . GetRequiredService < IDataStorage > ( ) ;
39
37
_capOptions = service . GetRequiredService < IOptions < CapOptions > > ( ) . Value ;
@@ -43,8 +41,8 @@ public CapPublisher(IServiceProvider service)
43
41
44
42
public IServiceProvider ServiceProvider { get ; }
45
43
46
- public ICapTransaction ? Transaction {
47
-
44
+ public ICapTransaction ? Transaction
45
+ {
48
46
get => _asyncLocal . Value ? . Transaction ;
49
47
set
50
48
{
@@ -114,11 +112,6 @@ public void PublishDelay<T>(TimeSpan delayTime, string name, T? value, string? c
114
112
private async Task PublishInternalAsync < T > ( string name , T ? value , IDictionary < string , string ? > headers , TimeSpan ? delayTime = null ,
115
113
CancellationToken cancellationToken = default )
116
114
{
117
- if ( ! _bootstrapper . IsStarted )
118
- {
119
- throw new InvalidOperationException ( "CAP has not been started!" ) ;
120
- }
121
-
122
115
if ( string . IsNullOrEmpty ( name ) ) throw new ArgumentNullException ( nameof ( name ) ) ;
123
116
124
117
if ( ! string . IsNullOrEmpty ( _capOptions . TopicNamePrefix ) ) name = $ "{ _capOptions . TopicNamePrefix } .{ name } ";
@@ -176,8 +169,7 @@ private async Task PublishInternalAsync<T>(string name, T? value, IDictionary<st
176
169
{
177
170
var transaction = ( CapTransactionBase ) Transaction ;
178
171
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 ) ;
181
173
182
174
TracingAfter ( tracingTimestamp , message ) ;
183
175
0 commit comments