Documentation ¶
Index ¶
- Constants
- Variables
- func FulltextMatch(expectedProtocol string) func(string) bool
- func GenerateRequestID() []byte
- func GetPubSubTopicFromContentTopic(cTopicString string) (string, error)
- func PrefixTextMatch(prefix string) func(protocol.ID) bool
- type CommonService
- type ContentFilter
- type ContentTopic
- type ContentTopicOption
- type ContentTopicParams
- type ContentTopicSet
- type Envelope
- type NamedShardingPubsubTopic
- type NamespacedPubsubTopic
- type NamespacedPubsubTopicKind
- type RelayShards
- func (rs RelayShards) BitVector() []byte
- func (rs RelayShards) Contains(cluster uint16, index uint16) bool
- func (rs RelayShards) ContainsNamespacedTopic(topic NamespacedPubsubTopic) bool
- func (rs RelayShards) ContainsTopic(topic string) bool
- func (rs RelayShards) IndicesList() ([]byte, error)
- func (rs RelayShards) Topics() []NamespacedPubsubTopic
- type StaticShardingPubsubTopic
- func (s StaticShardingPubsubTopic) Cluster() uint16
- func (s StaticShardingPubsubTopic) Equal(t2 NamespacedPubsubTopic) bool
- func (s StaticShardingPubsubTopic) Kind() NamespacedPubsubTopicKind
- func (s *StaticShardingPubsubTopic) Parse(topic string) error
- func (s StaticShardingPubsubTopic) Shard() uint16
- func (s StaticShardingPubsubTopic) String() string
Constants ¶
const ClusterIndex = 1
ClusterIndex is the clusterID used in sharding space. For indices allocation and other magic numbers refer to RFC 51
const DefaultContentTopic = "/waku/2/default-content/proto"
DefaultContentTopic is the default content topic used in Waku network if no content topic is specified.
const GenerationZeroShardsCount = 8
GenerationZeroShardsCount is number of shards supported in generation-0
const GossipSubOptimalFullMeshSize = 6
const MaxShardIndex = uint16(1023)
const StaticShardingPubsubTopicPrefix = Waku2PubsubTopicPrefix + "/rs"
StaticShardingPubsubTopicPrefix is the expected prefix to be used for static sharding pubsub topics
const Waku2PubsubTopicPrefix = "/waku/2"
Waku2PubsubTopicPrefix is the expected prefix to be used for pubsub topics
Variables ¶
var ErrAlreadyStarted = errors.New("already started")
var ErrInvalidFormat = errors.New("invalid format")
var ErrInvalidGeneration = errors.New("generation should be a number")
var ErrInvalidNumberFormat = errors.New("only 2^16 numbers are allowed")
ErrInvalidNumberFormat indicates that a number exceeds the allowed range
var ErrInvalidShardedTopicPrefix = errors.New("must start with " + StaticShardingPubsubTopicPrefix)
var ErrInvalidStructure = errors.New("invalid topic structure")
ErrInvalidStructure indicates that the pubsub topic is malformed
var ErrInvalidTopicPrefix = errors.New("must start with " + Waku2PubsubTopicPrefix)
ErrInvalidTopicPrefix indicates that the pubsub topic is missing the prefix /waku/2
var ErrMissingClusterIndex = errors.New("missing shard_cluster_index")
var ErrMissingGeneration = errors.New("missing part: generation")
var ErrMissingShardNumber = errors.New("missing shard_number")
var ErrMissingTopicName = errors.New("missing topic-name")
var ErrNotStarted = errors.New("not started")
Functions ¶
func FulltextMatch ¶
FulltextMatch is the default matching function used for checking if a peer supports a protocol or not
func GenerateRequestID ¶ added in v0.8.0
func GenerateRequestID() []byte
GenerateRequestID generates a random 32 byte slice that can be used for creating requests inf the filter, store and lightpush protocols
func GetPubSubTopicFromContentTopic ¶ added in v0.8.1
Types ¶
type CommonService ¶ added in v0.8.0
this is common layout for all the services that require mutex protection and a guarantee that all running goroutines will be finished before stop finishes execution. This guarantee comes from waitGroup all one has to use CommonService.WaitGroup() in the goroutines that should finish by the end of stop function.
func NewCommonService ¶ added in v0.8.0
func NewCommonService() *CommonService
func (*CommonService) Context ¶ added in v0.8.0
func (sp *CommonService) Context() context.Context
func (*CommonService) ErrOnNotRunning ¶ added in v0.8.0
func (sp *CommonService) ErrOnNotRunning() error
This is not a mutex protected function, it is up to the caller to use it in a mutex protected context
func (*CommonService) Start ¶ added in v0.8.0
func (sp *CommonService) Start(ctx context.Context, fn func() error) error
mutex protected start function creates internal context over provided context and runs fn safely fn is excerpt to be executed to start the protocol
func (*CommonService) Stop ¶ added in v0.8.0
func (sp *CommonService) Stop(fn func())
mutex protected stop function
func (*CommonService) WaitGroup ¶ added in v0.8.0
func (sp *CommonService) WaitGroup() *sync.WaitGroup
type ContentFilter ¶ added in v0.8.1
type ContentFilter struct { PubsubTopic string ContentTopics ContentTopicSet }
ContentFilter is used to specify the filter to be applied for a FilterNode. Topic means pubSubTopic - optional in case of using contentTopics that following Auto sharding, mandatory in case of named or static sharding. ContentTopics - Specify list of content topics to be filtered under a pubSubTopic (for named and static sharding), or a list of contentTopics (in case ofAuto sharding) If pubSub topic is not specified, then content-topics are used to derive the shard and corresponding pubSubTopic using autosharding algorithm
func NewContentFilter ¶ added in v0.8.1
func NewContentFilter(pubsubTopic string, contentTopics ...string) ContentFilter
func (ContentFilter) ContentTopicsList ¶ added in v0.8.1
func (cf ContentFilter) ContentTopicsList() []string
type ContentTopic ¶
type ContentTopic struct { ContentTopicParams ApplicationName string ApplicationVersion uint32 ContentTopicName string Encoding string }
ContentTopic is used for content based.
func NewContentTopic ¶
func NewContentTopic(applicationName string, applicationVersion uint32, contentTopicName string, encoding string, opts ...ContentTopicOption) (ContentTopic, error)
NewContentTopic creates a new content topic based on params specified. Returns ErrInvalidGeneration if an unsupported generation is specified.
func StringToContentTopic ¶
func StringToContentTopic(s string) (ContentTopic, error)
StringToContentTopic can be used to create a ContentTopic object from a string
func (ContentTopic) Equal ¶
func (ct ContentTopic) Equal(ct2 ContentTopic) bool
Equal to compare 2 content topics.
func (ContentTopic) String ¶
func (ct ContentTopic) String() string
String formats a content topic in string format as per RFC 23.
type ContentTopicOption ¶ added in v0.8.0
type ContentTopicOption func(*ContentTopicParams)
ContentTopicOption is following the options pattern to define optional params
func DefaultOptions ¶ added in v0.8.0
func DefaultOptions() []ContentTopicOption
DefaultOptions sets default values for contentTopic optional params.
func WithGeneration ¶ added in v0.8.0
func WithGeneration(generation int) ContentTopicOption
WithGeneration option can be used to specify explicitly a generation for contentTopic
type ContentTopicParams ¶ added in v0.8.0
type ContentTopicParams struct {
Generation int
}
ContentTopicParams contains all the optional params for a content topic
func (ContentTopicParams) Equal ¶ added in v0.8.0
func (ctp ContentTopicParams) Equal(ctp2 ContentTopicParams) bool
Equal method used to compare 2 contentTopicParams
type ContentTopicSet ¶ added in v0.8.1
type ContentTopicSet map[string]struct{}
func NewContentTopicSet ¶ added in v0.8.1
func NewContentTopicSet(contentTopics ...string) ContentTopicSet
type Envelope ¶
type Envelope struct {
// contains filtered or unexported fields
}
Envelope contains information about the pubsub topic of a WakuMessage and a hash used to identify a message based on the bytes of a WakuMessage protobuffer
func NewEnvelope ¶
func NewEnvelope(msg *wpb.WakuMessage, receiverTime int64, pubSubTopic string) *Envelope
NewEnvelope creates a new Envelope that contains a WakuMessage It's used as a way to know to which Pubsub topic belongs a WakuMessage as well as generating a hash based on the bytes that compose the message
func (*Envelope) Message ¶
func (e *Envelope) Message() *wpb.WakuMessage
Message returns the WakuMessage associated to an Envelope
func (*Envelope) PubsubTopic ¶
PubsubTopic returns the topic on which a WakuMessage was received
type NamedShardingPubsubTopic ¶ added in v0.5.2
type NamedShardingPubsubTopic struct { NamespacedPubsubTopic // contains filtered or unexported fields }
NamedShardingPubsubTopic is object for a NamedSharding type pubSub topic
func (NamedShardingPubsubTopic) Equal ¶ added in v0.5.2
func (n NamedShardingPubsubTopic) Equal(t2 NamespacedPubsubTopic) bool
Equal compares NamedShardingPubsubTopic
func (NamedShardingPubsubTopic) Kind ¶ added in v0.5.2
func (n NamedShardingPubsubTopic) Kind() NamespacedPubsubTopicKind
Kind returns the type of PubsubTopic whether it is StaticShared or NamedSharded
func (NamedShardingPubsubTopic) Name ¶ added in v0.5.2
func (n NamedShardingPubsubTopic) Name() string
Name is the name of the NamedSharded pubsub topic.
func (*NamedShardingPubsubTopic) Parse ¶ added in v0.5.2
func (n *NamedShardingPubsubTopic) Parse(topic string) error
Parse parses a topic string into a NamedShardingPubsubTopic
func (NamedShardingPubsubTopic) String ¶ added in v0.5.2
func (n NamedShardingPubsubTopic) String() string
String formats NamedShardingPubsubTopic to RFC 23 specific string format for pubsub topic.
type NamespacedPubsubTopic ¶ added in v0.6.0
type NamespacedPubsubTopic interface { String() string Kind() NamespacedPubsubTopicKind Equal(NamespacedPubsubTopic) bool }
NamespacedPubsubTopic is an interface for namespace based pubSub topic
func DefaultPubsubTopic ¶
func DefaultPubsubTopic() NamespacedPubsubTopic
DefaultPubsubTopic is the default pubSub topic used in waku
func NewNamedShardingPubsubTopic ¶ added in v0.5.2
func NewNamedShardingPubsubTopic(name string) NamespacedPubsubTopic
NewNamedShardingPubsubTopic creates a new NamedShardingPubSubTopic
func ToShardedPubsubTopic ¶ added in v0.5.2
func ToShardedPubsubTopic(topic string) (NamespacedPubsubTopic, error)
ToShardedPubsubTopic takes a pubSub topic string and creates a NamespacedPubsubTopic object.
type NamespacedPubsubTopicKind ¶ added in v0.5.2
type NamespacedPubsubTopicKind int
NamespacedPubsubTopicKind used to represent kind of NamespacedPubsubTopicKind
const ( StaticSharding NamespacedPubsubTopicKind = iota NamedSharding )
type RelayShards ¶ added in v0.6.0
func FromBitVector ¶ added in v0.6.0
func FromBitVector(buf []byte) (RelayShards, error)
Generate a RelayShards from a byte slice
func FromIndicesList ¶ added in v0.6.0
func FromIndicesList(buf []byte) (RelayShards, error)
func NewRelayShards ¶ added in v0.6.0
func NewRelayShards(cluster uint16, indices ...uint16) (RelayShards, error)
func TopicsToRelayShards ¶ added in v0.7.0
func TopicsToRelayShards(topic ...string) ([]RelayShards, error)
func (RelayShards) BitVector ¶ added in v0.6.0
func (rs RelayShards) BitVector() []byte
func (RelayShards) Contains ¶ added in v0.6.0
func (rs RelayShards) Contains(cluster uint16, index uint16) bool
func (RelayShards) ContainsNamespacedTopic ¶ added in v0.6.0
func (rs RelayShards) ContainsNamespacedTopic(topic NamespacedPubsubTopic) bool
func (RelayShards) ContainsTopic ¶ added in v0.6.0
func (rs RelayShards) ContainsTopic(topic string) bool
func (RelayShards) IndicesList ¶ added in v0.6.0
func (rs RelayShards) IndicesList() ([]byte, error)
func (RelayShards) Topics ¶ added in v0.6.0
func (rs RelayShards) Topics() []NamespacedPubsubTopic
type StaticShardingPubsubTopic ¶ added in v0.5.2
type StaticShardingPubsubTopic struct { NamespacedPubsubTopic // contains filtered or unexported fields }
StaticShardingPubsubTopic describes a pubSub topic as per StaticSharding
func GetShardFromContentTopic ¶ added in v0.8.0
func GetShardFromContentTopic(topic ContentTopic, shardCount int) StaticShardingPubsubTopic
GetShardFromContentTopic runs Autosharding logic and returns a pubSubTopic This is based on Autosharding algorithm defined in RFC 51
func NewStaticShardingPubsubTopic ¶ added in v0.5.2
func NewStaticShardingPubsubTopic(cluster uint16, shard uint16) StaticShardingPubsubTopic
NewStaticShardingPubsubTopic creates a new pubSub topic
func (StaticShardingPubsubTopic) Cluster ¶ added in v0.5.2
func (s StaticShardingPubsubTopic) Cluster() uint16
Cluster returns the sharded cluster index
func (StaticShardingPubsubTopic) Equal ¶ added in v0.5.2
func (s StaticShardingPubsubTopic) Equal(t2 NamespacedPubsubTopic) bool
Equal compares StaticShardingPubsubTopic
func (StaticShardingPubsubTopic) Kind ¶ added in v0.5.2
func (s StaticShardingPubsubTopic) Kind() NamespacedPubsubTopicKind
Kind returns the type of PubsubTopic whether it is StaticShared or NamedSharded
func (*StaticShardingPubsubTopic) Parse ¶ added in v0.5.2
func (s *StaticShardingPubsubTopic) Parse(topic string) error
Parse parses a topic string into a StaticShardingPubsubTopic
func (StaticShardingPubsubTopic) Shard ¶ added in v0.5.2
func (s StaticShardingPubsubTopic) Shard() uint16
Shard returns the shard number
func (StaticShardingPubsubTopic) String ¶ added in v0.5.2
func (s StaticShardingPubsubTopic) String() string
String formats StaticShardingPubsubTopic to RFC 23 specific string format for pubsub topic.