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-2020 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 {
Local LocalConfig `yaml:"local"`
Redis RedisConfig `yaml:"redis"`
}
Config defines Store configuration.
NOTE: By default, the LocalStore implementation is used. Redis configuration is ignored unless RedisConfig.Enabled is true.
type LocalConfig ¶ added in v0.1.6
LocalConfig defines LocalStore configuration.
type LocalStore ¶ added in v0.1.6
type LocalStore struct {
// contains filtered or unexported fields
}
LocalStore is an in-memory Store implementation.
func NewLocalStore ¶ added in v0.1.6
func NewLocalStore(config LocalConfig, clk clock.Clock) *LocalStore
NewLocalStore creates a new LocalStore.
func (*LocalStore) UpdatePeer ¶ added in v0.1.6
UpdatePeer implements Store.
type RedisConfig ¶
type RedisConfig struct {
Enabled bool `yaml:"enabled"`
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) UpdatePeer ¶
UpdatePeer writes p to Redis with a TTL.
type Store ¶
type Store interface {
// Close cleans up any Store resources.
Close()
// 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.