File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,21 @@ class Publisher<Message> implements why.pubsub.Publisher<Message> {
22
22
23
23
public function publish (message : Message ): Promise <Noise > {
24
24
var buffer = config .serialize (message ).toBuffer ();
25
- return Promise .ofJsPromise (channel .publish (config .exchange , config .routingKey , buffer )).noise ();
25
+ var routingKey = config .routingKey (message );
26
+ return Promise .ofJsPromise (channel .publish (config .exchange , routingKey , buffer )).noise ();
26
27
}
27
28
}
28
29
29
30
typedef PublisherConfig <Message > = {
30
31
final exchange : String ;
31
- final routingKey : String ;
32
+ final routingKey : RoutingKey < Message > ;
32
33
final serialize : Message -> Chunk ;
34
+ }
35
+
36
+ @:callable
37
+ abstract RoutingKey <Message >(Message -> String ) from Message -> String to Message -> String {
38
+ @:from
39
+ public static inline function ofString <Message >(v : String ): RoutingKey <Message > {
40
+ return _ -> v ;
41
+ }
33
42
}
You can’t perform that action at this time.
0 commit comments