urlservice

package
v0.0.0-...-396892a Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	CreateShort(ctx context.Context, origin string, opts ...grpc.CallOption) (string, error)
	GetOrigin(ctx context.Context, short string, opts ...grpc.CallOption) (string, error)
	Get(ctx context.Context, short string, opts ...grpc.CallOption) (*proto.URL, error)
}

Service represents wrapped grpc service.

func NewService

func NewService(conn *grpc.ClientConn) Service

NewService creates and wraps a new service.

type Shortener

type Shortener interface {
	Shorten(string) string
}

Shortener shortens a URL.

func NewCRC64Shortener

func NewCRC64Shortener(poly ...uint64) Shortener

NewCRC64Shortener creates a new shortener that uses CRC64 as a hash function.

type URLService

type URLService struct {
	proto.UnimplementedURLServiceServer
	// contains filtered or unexported fields
}

URLService implements proto.URLService interface.

func NewURLService

func NewURLService(repo repo.Repository, shortener ...Shortener) *URLService

NewURLService creates a new service.

func (*URLService) CreateShort

func (s *URLService) CreateShort(ctx context.Context, origin *proto.Origin) (*proto.Short, error)

CreateShort creates a short link.

func (*URLService) Get

func (s *URLService) Get(ctx context.Context, short *proto.Short) (*proto.URL, error)

Get returns an URL by short link.

func (*URLService) GetOrigin

func (s *URLService) GetOrigin(ctx context.Context, short *proto.Short) (*proto.Origin, error)

GetOrigin returns an origin link by short link.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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