package eventbus

import (
	
	
	
	
)

type subSettings struct {
	buffer int
	name   string
}

var subCnt atomic.Int64

var subSettingsDefault = subSettings{
	buffer: 16,
}

// newSubSettings returns the settings for a new subscriber
// The default naming strategy is sub-<fileName>-L<lineNum>
func newSubSettings() subSettings {
	 := subSettingsDefault
	, , ,  := runtime.Caller(2) // skip=1 is eventbus.Subscriber
	if  {
		 = strings.TrimPrefix(, "github.com/")
		// remove the version number from the path, for example
		// go-libp2p-package@v0.x.y-some-hash-123/file.go will be shortened go go-libp2p-package/file.go
		if  := strings.Index(, "@");  != -1 {
			if  := strings.Index([:], "/");  != -1 {
				 = [:] + [+:]
			}
		}
		.name = fmt.Sprintf("%s-L%d", , )
	} else {
		.name = fmt.Sprintf("subscriber-%d", subCnt.Add(1))
	}
	return 
}

func ( int) func(interface{}) error {
	return func( interface{}) error {
		.(*subSettings).buffer = 
		return nil
	}
}

func ( string) func(interface{}) error {
	return func( interface{}) error {
		.(*subSettings).name = 
		return nil
	}
}

type emitterSettings struct {
	makeStateful bool
}

// Stateful is an Emitter option which makes the eventbus channel
// 'remember' last event sent, and when a new subscriber joins the
// bus, the remembered event is immediately sent to the subscription
// channel.
//
// This allows to provide state tracking for dynamic systems, and/or
// allows new subscribers to verify that there are Emitters on the channel
func ( interface{}) error {
	.(*emitterSettings).makeStateful = true
	return nil
}

type Option func(*basicBus)

func ( MetricsTracer) Option {
	return func( *basicBus) {
		.metricsTracer = 
		.wildcard.metricsTracer = 
	}
}