package redis

import (
	

	
)

type PubSubCmdable interface {
	Publish(ctx context.Context, channel string, message interface{}) *IntCmd
	SPublish(ctx context.Context, channel string, message interface{}) *IntCmd
	PubSubChannels(ctx context.Context, pattern string) *StringSliceCmd
	PubSubNumSub(ctx context.Context, channels ...string) *MapStringIntCmd
	PubSubNumPat(ctx context.Context) *IntCmd
	PubSubShardChannels(ctx context.Context, pattern string) *StringSliceCmd
	PubSubShardNumSub(ctx context.Context, channels ...string) *MapStringIntCmd
}

// Publish posts the message to the channel.
func ( cmdable) ( context.Context,  string,  interface{}) *IntCmd {
	 := NewIntCmd(, "publish", , )
	_ = (, )
	// Record PubSub message sent (if command succeeded). Gated on the result
	// being readable WITHOUT blocking: on the deferred autopipeline face the
	// call above only enqueues, so reading the outcome here would await the
	// batch and turn a fire-and-forget publish into a blocking call — i.e.
	// enabling telemetry would change the async call shape (review finding by
	// codex on #3942). The metric is therefore skipped for a submission that
	// has not executed yet; recording it from the execution path instead is a
	// follow-up in the OTel wiring, not something the command wrapper can do.
	if otel.Enabled() && .resultReady() && .rawErr() == nil {
		otel.RecordPubSubMessage(, nil, "sent", , false)
	}
	return 
}

func ( cmdable) ( context.Context,  string,  interface{}) *IntCmd {
	 := NewIntCmd(, "spublish", , )
	_ = (, )
	// Record PubSub message sent (if command succeeded). See Publish for why
	// this is gated on the result being readable without blocking.
	if otel.Enabled() && .resultReady() && .rawErr() == nil {
		otel.RecordPubSubMessage(, nil, "sent", , true)
	}
	return 
}

func ( cmdable) ( context.Context,  string) *StringSliceCmd {
	 := []interface{}{"pubsub", "channels"}
	if  != "*" {
		 = append(, )
	}
	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  ...string) *MapStringIntCmd {
	 := make([]interface{}, 2+len())
	[0] = "pubsub"
	[1] = "numsub"
	for ,  := range  {
		[2+] = 
	}
	 := NewMapStringIntCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  string) *StringSliceCmd {
	 := []interface{}{"pubsub", "shardchannels"}
	if  != "*" {
		 = append(, )
	}
	 := NewStringSliceCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context,  ...string) *MapStringIntCmd {
	 := make([]interface{}, 2+len())
	[0] = "pubsub"
	[1] = "shardnumsub"
	for ,  := range  {
		[2+] = 
	}
	 := NewMapStringIntCmd(, ...)
	_ = (, )
	return 
}

func ( cmdable) ( context.Context) *IntCmd {
	 := NewIntCmd(, "pubsub", "numpat")
	_ = (, )
	return 
}