browsers

package
v0.30.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: MPL-2.0 Imports: 8 Imported by: 0

README

Browsers Service

Browser service provides read/write API for browser object.

To enable include browsers config part and add browsers to APIModules:

{
  "BrowsersConfig": {
    "Enabled": true,
  },
  APIModules: "browsers"
}

API

Enabling service will expose three additional methods:

browsers_addBrowser

Stores browser in the database. All fields are specified below:

{
  "browser-id": "1",
  "name": "first",
  "timestamp": 10,
  "dapp?": true,
  "history-index": 1,
  "history": [
    "one",
    "two"
  ]
}
browsers_getBrowsers

Reads all browsers, returns in the format specified above. List is sorted by timestamp.

browsers_deleteBrowser

Delete browser from database. Accepts browser id.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrServiceNotInitialized returned when wallet is not initialized/started,.
	ErrServiceNotInitialized = errors.New("browsers service is not initialized")
)

Functions

This section is empty.

Types

type API

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

API is class with methods available over RPC.

func NewAPI

func NewAPI(s *Service) *API

func (*API) AddBrowser

func (api *API) AddBrowser(ctx context.Context, browser Browser) error

func (*API) DeleteBrowser

func (api *API) DeleteBrowser(ctx context.Context, id string) error

func (*API) GetBrowsers

func (api *API) GetBrowsers(ctx context.Context) ([]*Browser, error)

type Browser

type Browser struct {
	ID           string   `json:"browser-id"`
	Name         string   `json:"name"`
	Timestamp    uint64   `json:"timestamp"`
	Dapp         bool     `json:"dapp?"`
	HistoryIndex int      `json:"history-index"`
	History      []string `json:"history,omitempty"`
}

type Database

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

Database sql wrapper for operations with browser objects.

func InitializeDB

func InitializeDB(path, password string) (*Database, error)

InitializeDB creates db file at a given path and applies migrations.

func (Database) Close

func (db Database) Close() error

Close closes database.

func (*Database) DeleteBrowser

func (db *Database) DeleteBrowser(id string) error

func (*Database) GetBrowsers

func (db *Database) GetBrowsers() (rst []*Browser, err error)

func (*Database) InsertBrowser

func (db *Database) InsertBrowser(browser Browser) (err error)

type Service

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

Service is a browsers service.

func NewService

func NewService() *Service

NewService initializes service instance.

func (*Service) APIs

func (s *Service) APIs() []rpc.API

APIs returns list of available RPC APIs.

func (*Service) Protocols

func (s *Service) Protocols() []p2p.Protocol

Protocols returns list of p2p protocols.

func (*Service) Start

func (s *Service) Start(*p2p.Server) error

Start a service.

func (*Service) StartDatabase

func (s *Service) StartDatabase(dbpath, password string) (err error)

Start database after dbpath and password will become known.

func (*Service) Stop

func (s *Service) Stop() error

Stop a service.

func (*Service) StopDatabase

func (s *Service) StopDatabase() error

Directories

Path Synopsis
sql

Jump to

Keyboard shortcuts

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