Documentation
¶
Index ¶
- func ChannelBaseName(name string) string
- func CreateDriver(conn broadcasting.ConnectionConfig, app foundation.Application) (broadcasting.Driver, error)
- func IsPresenceChannel(name string) bool
- func IsPrivateChannel(name string) bool
- func PresenceChannel(name string) string
- func PrivateChannel(name string) string
- func PublicChannel(name string) string
- type Application
- type BroadcastJob
- type Config
- type ServiceProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChannelBaseName ¶
func CreateDriver ¶
func CreateDriver(conn broadcasting.ConnectionConfig, app foundation.Application) (broadcasting.Driver, error)
func IsPresenceChannel ¶
func IsPrivateChannel ¶
func PresenceChannel ¶
func PrivateChannel ¶
func PublicChannel ¶
PublicChannel returns the channel name unchanged. It is kept as a semantic wrapper for readability and API stability, mirroring PrivateChannel and PresenceChannel (and Laravel's channel constructors): callers write broadcasting.PublicChannel("orders") instead of a bare "orders" string.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func NewApplication ¶
func NewApplication(configFacade contractsconfig.Config, log log.Log, queue queue.Queue, app foundation.Application) *Application
func (*Application) Authenticate ¶
func (a *Application) Authenticate(ctx contractshttp.Context) contractshttp.Response
func (*Application) Channel ¶
func (a *Application) Channel(pattern string, callback broadcasting.ChannelAuthFunc)
Channel registers an authorization callback for a channel pattern.
Example:
// Simple channel
facades.Broadcast().Channel("orders", func(ctx context.Context, userID any, channelName string, params map[string]string) (bool, any) {
return true, nil
})
// Channel with route params
facades.Broadcast().Channel("orders.{orderId}", func(ctx context.Context, userID any, channelName string, params map[string]string) (bool, any) {
// params["orderId"] contains the matched value
order := findOrder(ctx, params["orderId"])
return order.UserID == userID, nil
})
// Presence channel returning custom user info
facades.Broadcast().Channel("chat", func(ctx context.Context, userID any, channelName string, params map[string]string) (bool, any) {
return true, map[string]any{"id": userID, "name": "Alice"}
})
func (*Application) Dispatch ¶
func (a *Application) Dispatch(ctx context.Context, event broadcasting.ShouldBroadcast) error
Dispatch broadcasts an event. In the synchronous path (events implementing ShouldBroadcastNow with BroadcastNow()==true, or when no queue is available) ctx bounds the driver call. In the asynchronous path ctx is not propagated across the queue boundary; the worker synthesizes a new context, optionally bounded by ShouldBroadcastWithTimeout. The retry policy (BroadcastTries/BroadcastBackoff) is captured from the event's optional interfaces and enforced by the BroadcastJob's ShouldRetry at execution time.
type BroadcastJob ¶
type BroadcastJob struct {
// contains filtered or unexported fields
}
func (*BroadcastJob) Handle ¶
func (j *BroadcastJob) Handle(args ...any) error
Handle executes the queued broadcast. Retries are governed by ShouldRetry using the event's BroadcastTries/BroadcastBackoff captured at dispatch time. Broadcasts without BroadcastTries defer to the queue worker's tries config. A fresh context is synthesized (the dispatch-time ctx cannot cross the queue boundary); if the originating event implemented ShouldBroadcastWithTimeout the worker context is bounded accordingly, which the Pusher driver honours via WithContext.
func (*BroadcastJob) ShouldRetry ¶
func (j *BroadcastJob) ShouldRetry(err error, attempt, maxTries int) (retryable bool, delay time.Duration)
ShouldRetry controls retries for the queued broadcast. A BroadcastTries-declaring event wins; without one (Tries <= 0) the queue worker's maxTries governs. With a cap it retries while attempt < Tries using the configured per-attempt Backoff (last value repeats); backoff applies to worker-driven retries too. item == nil (cleared on success/invalid payload) is the safe single-shot fallback — never the worker's tries, so an interleaved concurrent task can't inherit another task's policy.
func (*BroadcastJob) Signature ¶
func (j *BroadcastJob) Signature() string
type Config ¶
type Config struct {
Default string `json:"default"`
Connections map[string]broadcasting.ConnectionConfig `json:"connections"`
Auth broadcasting.AuthConfig `json:"auth"`
}
func (*Config) Connection ¶
func (c *Config) Connection(name string) (broadcasting.ConnectionConfig, error)
func (*Config) DefaultConnection ¶
type ServiceProvider ¶
type ServiceProvider struct{}
func (*ServiceProvider) Boot ¶
func (r *ServiceProvider) Boot(app foundation.Application)
func (*ServiceProvider) Register ¶
func (r *ServiceProvider) Register(app foundation.Application)
func (*ServiceProvider) Relationship ¶
func (r *ServiceProvider) Relationship() binding.Relationship