peers

package
v0.0.0-...-e95280a Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const NormalProtocol = "https"

NormalProtocol represents the normal protocol

View Source
const TorProtocol = "tor"

TorProtocol represents the tor protocol

Variables

This section is empty.

Functions

func NewPeerPointer

func NewPeerPointer() *peer

NewPeerPointer returns a new peer pointer

func NewPointer

func NewPointer() *peers

NewPointer returns a new peers pointer

Types

type Builder

type Builder interface {
	Create() Builder
	WithID(id *uuid.UUID) Builder
	WithSyncDuration(syncDuration time.Duration) Builder
	WithList(list []Peer) Builder
	LastSyncTime(lastSyncTime time.Time) Builder
	Now() (Peers, error)
}

Builder represents a peers builder

func NewBuilder

func NewBuilder() Builder

NewBuilder creates a new builder instance

type Content

type Content interface {
	String() string
	IsNormal() bool
	Normal() Server
	IsTor() bool
	Tor() Server
}

Content represents a peer content

type Peer

type Peer interface {
	Content() Content
	CreatedOn() time.Time
	LastUpdatedOn() time.Time
}

Peer represents a peer

func CreatePeerForTests

func CreatePeerForTests() Peer

CreatePeerForTests creates a new peer instance for tests

type PeerBuilder

type PeerBuilder interface {
	Create() PeerBuilder
	WithOriginal(original Peer) PeerBuilder
	WithServer(server string) PeerBuilder
	CreatedOn(createdOn time.Time) PeerBuilder
	LastUpdatedOn(lastUpdatedOn time.Time) PeerBuilder
	Now() (Peer, error)
}

PeerBuilder represents a peers builder

func NewPeerBuilder

func NewPeerBuilder() PeerBuilder

NewPeerBuilder creates a new peer builder instance

type Peers

type Peers interface {
	ID() *uuid.UUID
	SyncInterval() time.Duration
	All() []Peer
	Add(ins Peer) error
	Merge(ins Peers)
	Delete(ins Peer) error
	HasLastSync() bool
	LastSync() *time.Time
}

Peers represents a peer list

func CreatePeersForTests

func CreatePeersForTests() Peers

CreatePeersForTests creates a new peers instance for tests

type Server

type Server interface {
	Host() string
	Port() uint
	String() string
}

Server represents a peer server

Jump to

Keyboard shortcuts

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