userprofile

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCliFlags

func NewCliFlags() []cli.Flag

NewCliFlags returns cli flags to configure a core client.

Types

type AddrHeap

type AddrHeap []AddrNode

AddrHeap is a min-heap of AddrNode

func (AddrHeap) Len

func (a AddrHeap) Len() int

Len return the length of addrHeap

func (AddrHeap) Less

func (a AddrHeap) Less(i, j int) bool

Less return bool indicate the comparision between 2 AddrNode by index

func (*AddrHeap) Pop

func (a *AddrHeap) Pop() interface{}

Pop return the root and delete it from heap

func (*AddrHeap) Push

func (a *AddrHeap) Push(x interface{})

Push Add the addrNode to heap

func (AddrHeap) Swap

func (a AddrHeap) Swap(i, j int)

Swap swap 2 node value

type AddrNode

type AddrNode struct {
	Timestamp uint64
	Addr      string
}

AddrNode represent a node in heap. It minimize the data that needs to be stored.

type CachedClient

type CachedClient struct {
	*Client

	MaxCacheSize int64
	// contains filtered or unexported fields
}

CachedClient is the wrapper of User Profile Client with caching ability.

func NewCachedClient

func NewCachedClient(client *Client, maxCache int64) *CachedClient

NewCachedClient creates a new User Profile cached client instance.

func NewCachedClientFromContext

func NewCachedClientFromContext(client *Client, c *cli.Context) *CachedClient

NewCachedClientFromContext return new cached client from cli flags

func (*CachedClient) LookUpCache

func (cc *CachedClient) LookUpCache(addr ethereum.Address) (UserProfile, bool)

LookUpCache will lookup the Userprofile from cache

func (*CachedClient) LookUpUserProfile

func (cc *CachedClient) LookUpUserProfile(addr ethereum.Address) (UserProfile, error)

LookUpUserProfile will look for the UserProfile of input addr in cache first If this fail then it will query from endpoint

type Client

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

Client is the the implementation to query userprofile info.

func NewClient

func NewClient(sugar *zap.SugaredLogger, url, signingKey string) (*Client, error)

NewClient creates a new core client instance.

func NewClientFromContext

func NewClientFromContext(sugar *zap.SugaredLogger, c *cli.Context) (*Client, error)

NewClientFromContext returns new core client from cli flags.

func (*Client) LookUpUserProfile

func (c *Client) LookUpUserProfile(addr ethereum.Address) (UserProfile, error)

LookUpUserProfile will look for the UserProfile of input addr from server

type Interface

type Interface interface {
	LookUpUserProfile(addr ethereum.Address) (UserProfile, error)
}

Interface define functionality of this package

type MockClient

type MockClient struct{}

MockClient is the mock implementation of user profile Interface

func (MockClient) LookUpUserProfile

func (m MockClient) LookUpUserProfile(addr ethereum.Address) (UserProfile, error)

LookUpUserProfile return mockUserName and MockID for testing purpose

type UserProfile

type UserProfile struct {
	UserName  string `json:"name"`
	ProfileID int64  `json:"profile_id"`
}

UserProfile contain infos of a user

Jump to

Keyboard shortcuts

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