add RedisChannel UseImplicitAutoPattern and IsPatternBased by mgravell · Pull Request #2480 · StackExchange/StackExchange.Redis (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@mgravell

@mgravell

philon-msft

get => s_DefaultPatternMode == PatternMode.Auto;
set => s_DefaultPatternMode = value ? PatternMode.Auto : PatternMode.Literal;
}
private static PatternMode s_DefaultPatternMode = PatternMode.Auto;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a property to ConfigurationOptions to control this default?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't; ConfigurationOptions is per-instance, this is global; existing code like (RedisChannel)"abc" is not aware of any config model, so would have nowhere to get the info from, and if we try to make ConfigurationOptions touch the global setting, then it will be "last model wins", which is ultra unfriendly; at least the global nature is clear

philon-msft

@mgravell

mark the implicit RedisChannel operators as [Obsolete]

@arteny

You marked string initialization of RedisChannel as Obsolete, but there is no any doumentation how to use new RedisChannel functions.

@mgravell

The obsolete message literally gives that guidance, but yes we should check for any existing docs and update

@arteny

The obsolete message literally gives that guidance, but yes we should check for any existing docs and update

A guidance? It raises questions only.
Warning CS0618 'RedisChannel.implicit operator RedisChannel(string)' is obsolete: 'It is preferable to explicitly specify a PatternMode, or use the Literal/Pattern methods'

What is PatternMode and Literal/Pattern methods?

@mgravell

I will revise the message, and improve the docs, but to give you an answer today: RwdisChannel.Literal / RedisChannel.Pattern, or the RedisChannel constructor that takes a PatternMode

@arteny

ok, understood now, so instead of providing string key for subscribe, we need to use RedisChannel.Literal(key) or RedisChannel.Pattern(keysPattern) if using patterns

@mgravell

You can still use a string if you eat the CS0618 - and if you want to use the old behaviour without the warning, the constructor (explicitly stating .Auto as the enum) achieves that. It is ambiguous though, and might not be advisable in all scenarios. The design is regretted, and we would prefer to make people ask themselves "am I subscribing to a single literal channel, or to a pattern of channels?"

@jeffputz

Just getting around to a package update. This obsolete message still completely lacks context, and all I've been able to find is this PR, which is also absent intent of the change.

@mgravell

I'll try to improve that. Short version:

@jeffputz

@mgravell that makes sense, thank you. I think the missing context was that, until this, I wasn't aware that wildcards were possible in the pub/sub, so that's something new to me. I can't think of any situations where I would want to do that, but I suppose someone else could.

@mgravell

Right; so use RedisChannel.Literal - job done

@joshbartley

@mgravell

Labels