Documentation ¶
Overview ¶
Copyright (c) 2016-2019 Uber Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2016-2019 Uber Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2016-2019 Uber Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2016-2019 Uber Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright (c) 2016-2019 Uber Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func Sort(events []*Event)
- type Config
- type Event
- func AddActiveConnEvent(h core.InfoHash, self core.PeerID, peer core.PeerID) *Event
- func AddTorrentEvent(h core.InfoHash, self core.PeerID, b *bitset.BitSet, connCapacity int) *Event
- func BlacklistConnEvent(h core.InfoHash, self core.PeerID, peer core.PeerID, dur time.Duration) *Event
- func DropActiveConnEvent(h core.InfoHash, self core.PeerID, peer core.PeerID) *Event
- func Filter(events []*Event, names ...Name) []*Event
- func ReceivePieceEvent(h core.InfoHash, self core.PeerID, peer core.PeerID, piece int) *Event
- func RequestPieceEvent(h core.InfoHash, self core.PeerID, peer core.PeerID, piece int) *Event
- func StripTimestamps(events []*Event) []*Event
- func TorrentCancelledEvent(h core.InfoHash, self core.PeerID) *Event
- func TorrentCompleteEvent(h core.InfoHash, self core.PeerID) *Event
- type Name
- type Producer
- type TestProducer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Event ¶
type Event struct { Name Name `json:"event"` Torrent string `json:"torrent"` Self string `json:"self"` Time time.Time `json:"ts"` // Optional fields. Peer string `json:"peer,omitempty"` Piece int `json:"piece,omitempty"` Bitfield []bool `json:"bitfield,omitempty"` DurationMS int64 `json:"duration_ms,omitempty"` ConnCapacity int `json:"conn_capacity,omitempty"` }
Event consolidates all possible event fields.
func AddActiveConnEvent ¶
AddActiveConnEvent returns an event for an added active conn from self to peer.
func AddTorrentEvent ¶
AddTorrentEvent returns an event for an added torrent with initial bitfield.
func BlacklistConnEvent ¶
func BlacklistConnEvent(h core.InfoHash, self core.PeerID, peer core.PeerID, dur time.Duration) *Event
BlacklistConnEvent returns an event for a blacklisted connection.
func DropActiveConnEvent ¶
DropActiveConnEvent returns an event for a dropped active conn from self to peer.
func ReceivePieceEvent ¶
ReceivePieceEvent returns an event for a piece received from a peer.
func RequestPieceEvent ¶ added in v0.1.2
RequestPieceEvent returns an event for a piece request sent to a peer.
func StripTimestamps ¶
StripTimestamps overwrites timestamps in events as empty, allowing clients to check equality of events.
Mutates events in place and returns events for chaining purposes.
func TorrentCancelledEvent ¶
TorrentCancelledEvent returns an event for a cancelled torrent.
func TorrentCompleteEvent ¶
TorrentCompleteEvent returns an event for a completed torrent.
type Name ¶
type Name string
Name defines event names.
const ( AddTorrent Name = "add_torrent" AddActiveConn Name = "add_active_conn" DropActiveConn Name = "drop_active_conn" BlacklistConn Name = "blacklist_conn" RequestPiece Name = "request_piece" ReceivePiece Name = "receive_piece" TorrentComplete Name = "torrent_complete" TorrentCancelled Name = "torrent_cancelled" )
Possible event names.
type TestProducer ¶
TestProducer records all produced events.
func NewTestProducer ¶
func NewTestProducer() *TestProducer
NewTestProducer returns a new TestProducer.
func (*TestProducer) Events ¶
func (p *TestProducer) Events() []*Event
Events returns all currently recorded events.