peerstore

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Redis RedisConfig `yaml:"redis"`
}

Config defines Store configuration.

type RedisConfig

type RedisConfig struct {
	Addr              string        `yaml:"addr"`
	DialTimeout       time.Duration `yaml:"dial_timeout"`
	ReadTimeout       time.Duration `yaml:"read_timeout"`
	WriteTimeout      time.Duration `yaml:"write_timeout"`
	PeerSetWindowSize time.Duration `yaml:"peer_set_window_size"`
	MaxPeerSetWindows int           `yaml:"max_peer_set_windows"`
	MaxIdleConns      int           `yaml:"max_idle_conns"`
	MaxActiveConns    int           `yaml:"max_active_conns"`
	IdleConnTimeout   time.Duration `yaml:"idle_conn_timeout"`
}

RedisConfig defines RedisStore configuration. TODO(evelynl94): rename

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore is a Store backed by Redis.

func NewRedisStore

func NewRedisStore(config RedisConfig, clk clock.Clock) (*RedisStore, error)

NewRedisStore creates a new RedisStore.

func (*RedisStore) GetPeers

func (s *RedisStore) GetPeers(h core.InfoHash, n int) ([]*core.PeerInfo, error)

GetPeers returns at most n PeerInfos associated with h.

func (*RedisStore) UpdatePeer

func (s *RedisStore) UpdatePeer(h core.InfoHash, p *core.PeerInfo) error

UpdatePeer writes p to Redis with a TTL.

type Store

type Store interface {

	// GetPeers returns at most n random peers announcing for h.
	GetPeers(h core.InfoHash, n int) ([]*core.PeerInfo, error)

	// UpdatePeer updates peer fields.
	UpdatePeer(h core.InfoHash, peer *core.PeerInfo) error
}

Store provides storage for announcing peers.

func NewTestStore

func NewTestStore() Store

TestStore returns a thread-safe, in-memory peer store for testing purposes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL