Documentation ¶
Index ¶
- Constants
- Variables
- func ContentFilterToPubSubTopicMap(contentFilter ContentFilter) (map[PubsubTopicStr][]ContentTopicStr, error)
- func FulltextMatch(expectedProtocol string) func(string) bool
- func GeneratePubsubToContentTopicMap(pubsubTopic string, contentTopics []string) (map[string][]string, error)
- func GenerateRequestID() []byte
- func GetPubSubTopicFromContentTopic(cTopicString string) (string, error)
- func PrefixTextMatch(prefix string) func(protocol.ID) bool
- type ContentFilter
- type ContentTopic
- type ContentTopicOption
- type ContentTopicParams
- type ContentTopicSet
- type ContentTopicStr
- type DefaultPubsubTopic
- type Envelope
- type PubsubTopicStr
- type RelayShards
- func (rs RelayShards) BitVector() []byte
- func (rs RelayShards) Contains(cluster uint16, index uint16) bool
- func (rs RelayShards) ContainsShardPubsubTopic(topic WakuPubSubTopic) bool
- func (rs RelayShards) ContainsTopic(topic string) bool
- func (rs RelayShards) ShardList() ([]byte, error)
- func (rs RelayShards) Topics() []WakuPubSubTopic
- type StaticShardingPubsubTopic
- type WakuPubSubTopic
Constants ¶
const ClusterIndex = 1
ClusterIndex is the clusterID used in sharding space. For shardIDs allocation and other magic numbers refer to RFC 51
const GenerationZeroShardsCount = 8
GenerationZeroShardsCount is number of shards supported in generation-0
const GossipSubOptimalFullMeshSize = 6
const MaxShardIndex = uint16(1023)
const StaticShardingPubsubTopicPrefix = "/waku/2/rs"
StaticShardingPubsubTopicPrefix is the expected prefix to be used for static sharding pubsub topics
Variables ¶
var ( ErrTooManyShards = errors.New("too many shards") ErrInvalidShard = errors.New("invalid shard") ErrInvalidShardCount = errors.New("invalid shard count") ErrExpected130Bytes = errors.New("invalid data: expected 130 bytes") )
var ErrInvalidFormat = errors.New("invalid content topic 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")
var ErrMissingClusterIndex = errors.New("missing shard_cluster_index")
var ErrMissingGeneration = errors.New("missing part: generation")
var ErrMissingShardNumber = errors.New("missing shard_number")
var ErrNotShardPubsubTopic = errors.New("not a shard pubsub topic")
shard pubsub topic errors
var ErrNotWakuPubsubTopic = errors.New("not a waku pubsub topic")
waku pubsub topic errors
Functions ¶
func ContentFilterToPubSubTopicMap ¶ added in v0.9.0
func ContentFilterToPubSubTopicMap(contentFilter ContentFilter) (map[PubsubTopicStr][]ContentTopicStr, error)
This function converts a contentFilter into a map of pubSubTopics and corresponding contentTopics
func FulltextMatch ¶
FulltextMatch is the default matching function used for checking if a peer supports a protocol or not
func GeneratePubsubToContentTopicMap ¶ added in v0.9.0
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 ContentFilter ¶ added in v0.8.1
type ContentFilter struct { PubsubTopic string `json:"pubsubTopic"` ContentTopics ContentTopicSet `json:"contentTopics"` }
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
func (ContentFilter) Equals ¶ added in v0.9.0
func (cf ContentFilter) Equals(cf1 ContentFilter) bool
type ContentTopic ¶
type ContentTopic struct { ContentTopicParams ApplicationName string ApplicationVersion string ContentTopicName string Encoding string }
ContentTopic is used for content based.
func NewContentTopic ¶
func NewContentTopic(applicationName string, applicationVersion string, 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. Note that this is recommended to be used for autosharding where contentTopic format is enforced as per https://rfc.vac.dev/spec/51/#content-topics-format-for-autosharding
func StringToContentTopic ¶
func StringToContentTopic(s string) (ContentTopic, error)
StringToContentTopic can be used to create a ContentTopic object from a string Note that this has to be used only when following the rfc format of contentTopic, which is currently validated only for Autosharding. For static and named-sharding, contentTopic can be of any format and hence it is not recommended to use this function. This can be updated if required to handle such a case.
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
func (ContentTopicSet) ToList ¶ added in v0.9.0
func (cf ContentTopicSet) ToList() []string
type ContentTopicStr ¶ added in v0.9.0
type ContentTopicStr = string
type DefaultPubsubTopic ¶
type DefaultPubsubTopic struct{}
func (DefaultPubsubTopic) String ¶ added in v0.9.0
func (DefaultPubsubTopic) String() string
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 PubsubTopicStr ¶ added in v0.9.0
type PubsubTopicStr = string
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 FromShardList ¶ added in v0.9.0
func FromShardList(buf []byte) (RelayShards, error)
func NewRelayShards ¶ added in v0.6.0
func NewRelayShards(clusterID uint16, shardIDs ...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) ContainsShardPubsubTopic ¶ added in v0.9.0
func (rs RelayShards) ContainsShardPubsubTopic(topic WakuPubSubTopic) bool
func (RelayShards) ContainsTopic ¶ added in v0.6.0
func (rs RelayShards) ContainsTopic(topic string) bool
func (RelayShards) ShardList ¶ added in v0.9.0
func (rs RelayShards) ShardList() ([]byte, error)
func (RelayShards) Topics ¶ added in v0.6.0
func (rs RelayShards) Topics() []WakuPubSubTopic
type StaticShardingPubsubTopic ¶ added in v0.5.2
type StaticShardingPubsubTopic struct {
// 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 ToShardPubsubTopic ¶ added in v0.9.0
func ToShardPubsubTopic(topic WakuPubSubTopic) (StaticShardingPubsubTopic, error)
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 StaticShardingPubsubTopic) bool
Equal compares StaticShardingPubsubTopic
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.
type WakuPubSubTopic ¶ added in v0.9.0
type WakuPubSubTopic interface {
String() string
}
func ToWakuPubsubTopic ¶ added in v0.9.0
func ToWakuPubsubTopic(topic string) (WakuPubSubTopic, error)
ToWakuPubsubTopic takes a pubSub topic string and creates a WakuPubsubTopic object.