Skip to content

Commit 086571c

Browse files
committed
Revert "Add support for routing messages based on attribute decoration"
This reverts commit 5e5d77b.
1 parent 5e5d77b commit 086571c

File tree

7 files changed

+8
-98
lines changed

7 files changed

+8
-98
lines changed

src/Testing/CoreTests/Runtime/Green/Messages.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ public class GreenMessage1;
44

55
public class GreenMessage2;
66

7-
public class GreenMessage3;
8-
9-
public class GreenAttribute : Attribute;
7+
public class GreenMessage3;
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
namespace CoreTests.Runtime.Red;
22

3-
[Red]
43
public class RedMessage1;
54

6-
[Crimson]
75
public class RedMessage2;
86

9-
[Burgundy]
10-
public class RedMessage3;
11-
12-
public class RedAttribute : Attribute;
13-
14-
public class CrimsonAttribute : RedAttribute;
15-
16-
public class BurgundyAttribute : RedAttribute;
7+
public class RedMessage3;

src/Testing/CoreTests/Runtime/SubscriptionTester.cs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,6 @@ public void description_of_type_name_rule()
4545
rule.ToString().ShouldBe("Message name is 'CoreTests.Runtime.RandomClass'");
4646
}
4747

48-
[Fact]
49-
public void description_of_attribute_rule()
50-
{
51-
var rule = new Subscription
52-
{
53-
BaseOrAttributeType = typeof(RandomClassAttribute),
54-
Scope = RoutingScope.Attribute
55-
};
56-
rule.ToString().ShouldBe("Message type is decorated with 'CoreTests.Runtime.RandomClassAttribute' or a derived type");
57-
}
58-
5948
[Fact]
6049
public void description_of_all_types()
6150
{
@@ -96,20 +85,6 @@ public void positive_assembly_test()
9685
rule.Matches(typeof(DeleteUser)).ShouldBeTrue();
9786
}
9887

99-
[Fact]
100-
public void negative_attribute_test()
101-
{
102-
var rule = new Subscription
103-
{
104-
Scope = RoutingScope.Attribute,
105-
BaseOrAttributeType = typeof(GreenAttribute)
106-
};
107-
108-
rule.Matches(typeof(GreenMessage1)).ShouldBeFalse();
109-
rule.Matches(typeof(GreenMessage2)).ShouldBeFalse();
110-
rule.Matches(typeof(GreenMessage3)).ShouldBeFalse();
111-
}
112-
11388
[Fact]
11489
public void positive_namespace_test()
11590
{
@@ -123,23 +98,6 @@ public void positive_namespace_test()
12398
rule.Matches(typeof(RedMessage2)).ShouldBeTrue();
12499
rule.Matches(typeof(RedMessage3)).ShouldBeTrue();
125100
}
126-
127-
[Fact]
128-
public void positive_attribute_test()
129-
{
130-
var rule = new Subscription
131-
{
132-
Scope = RoutingScope.Attribute,
133-
BaseOrAttributeType = typeof(RedAttribute)
134-
};
135-
136-
rule.Matches(typeof(RedMessage1)).ShouldBeTrue();
137-
rule.Matches(typeof(RedMessage2)).ShouldBeTrue();
138-
rule.Matches(typeof(RedMessage3)).ShouldBeTrue();
139-
}
140101
}
141102

142-
[RandomClass]
143-
public class RandomClass;
144-
145-
public class RandomClassAttribute : Attribute;
103+
public class RandomClass;

src/Wolverine/Configuration/PublishingExpression.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -160,35 +160,6 @@ public PublishingExpression MessagesFromAssemblyContaining<T>()
160160
return MessagesFromAssembly(typeof(T).Assembly);
161161
}
162162

163-
/// <summary>
164-
/// Create a publishing rule for all messages decorated with the specified attribute type or a derived type
165-
/// </summary>
166-
/// <param name="attributeType"></param>
167-
/// <returns></returns>
168-
public PublishingExpression MessagesDecoratedWith(Type attributeType)
169-
{
170-
AutoAddSubscriptions = true;
171-
172-
_subscriptions.Add(new Subscription()
173-
{
174-
Scope = RoutingScope.Attribute,
175-
BaseOrAttributeType = attributeType,
176-
});
177-
178-
return this;
179-
}
180-
181-
/// <summary>
182-
/// Create a publishing rule for all messages decorated with the attribute of type T or a derived type
183-
/// </summary>
184-
/// <typeparam name="T"></typeparam>
185-
/// <returns></returns>
186-
public PublishingExpression MessagesDecoratedWith<T>()
187-
where T : Attribute
188-
{
189-
return MessagesDecoratedWith(typeof(T));
190-
}
191-
192163
internal void AttachSubscriptions()
193164
{
194165
if (!_endpoints.Any())
@@ -211,6 +182,6 @@ internal void AddSubscriptionForAllMessages()
211182
/// <typeparam name="T"></typeparam>
212183
public void MessagesImplementing<T>()
213184
{
214-
_subscriptions.Add(new Subscription { BaseOrAttributeType = typeof(T), Scope = RoutingScope.Implements });
185+
_subscriptions.Add(new Subscription { BaseType = typeof(T), Scope = RoutingScope.Implements });
215186
}
216187
}

src/Wolverine/Runtime/Routing/RoutingScope.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ public enum RoutingScope
77
Type,
88
TypeName,
99
All,
10-
Implements,
11-
Attribute
10+
Implements
1211
}

src/Wolverine/Runtime/Routing/Subscription.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ public string[] ContentTypes
4343
/// </summary>
4444
public string Match { get; init; } = string.Empty;
4545

46-
/// <summary>
47-
/// A base type if matching on implementation or an attribute type if matching on decoration
48-
/// </summary>
49-
public Type? BaseOrAttributeType { get; init; }
46+
public Type? BaseType { get; init; }
5047

5148
/// <summary>
5249
/// Create a subscription for a specific message type
@@ -83,8 +80,7 @@ public bool Matches(Type type)
8380
RoutingScope.Type => type.Name.EqualsIgnoreCase(Match) || type.FullName!.EqualsIgnoreCase(Match) ||
8481
type.ToMessageTypeName().EqualsIgnoreCase(Match),
8582
RoutingScope.TypeName => type.ToMessageTypeName().EqualsIgnoreCase(Match),
86-
RoutingScope.Implements => type.CanBeCastTo(BaseOrAttributeType!),
87-
RoutingScope.Attribute => type.IsDefined(BaseOrAttributeType!, inherit: false),
83+
RoutingScope.Implements => type.CanBeCastTo(BaseType!),
8884
_ => !type.CanBeCastTo<IAgentCommand>()
8985
};
9086
}
@@ -144,9 +140,6 @@ public override string ToString()
144140

145141
case RoutingScope.TypeName:
146142
return $"Message name is '{Match}'";
147-
148-
case RoutingScope.Attribute:
149-
return $"Message type is decorated with '{BaseOrAttributeType?.FullName}' or a derived type";
150143
}
151144

152145
throw new ArgumentOutOfRangeException();

src/Wolverine/Transports/Local/LocalTransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public LocalTransport() : base(TransportConstants.Local, "Local (In Memory)")
3636
var agentQueue = _queues[TransportConstants.Agents];
3737
agentQueue.TelemetryEnabled = false;
3838
agentQueue.Subscriptions.Add(new Subscription
39-
{ Scope = RoutingScope.Implements, BaseOrAttributeType = typeof(IAgentCommand) });
39+
{ Scope = RoutingScope.Implements, BaseType = typeof(IAgentCommand) });
4040
agentQueue.ExecutionOptions.MaxDegreeOfParallelism = 20;
4141
agentQueue.Role = EndpointRole.System;
4242
agentQueue.Mode = EndpointMode.BufferedInMemory;

0 commit comments

Comments
 (0)