services

package
v0.0.0-...-e249f0d Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConstructBoolQuery

func ConstructBoolQuery(key string, value string) *map[string]interface{}

ConstructBoolQuery returns a query for the SearchWithKeyWord method

func CreateNewDocumentInIndex

func CreateNewDocumentInIndex(index string, document *Document) error

CreateNewDocumentInIndex inserts a new document in elastic search. take the index and a pointer of Document as parameters. returns an error

func CreateNewIndex

func CreateNewIndex(index string, mapping string) error

CreateNewIndex allows you to create a new elastic search index. Checks if index already exists

func GenerateToken

func GenerateToken(email string) (string, error)

GenerateToken creates a JWT with email and expiration time in the payload

func HashPassword

func HashPassword(password string) string

HashPassword takes a string in parameter and returns the same string hashed with sha512

func MigrateIndex

func MigrateIndex() error

Migrate all the necessary indexes

Types

type Claims

type Claims struct {
	Email string
	jwt.StandardClaims
}

Claims is the struct for the token claims

func DecodeToken

func DecodeToken(tokenString string) (*jwt.Token, *Claims, error)

DecodeToken decode and validates a token

type Document

type Document struct {
	ID   string
	Body interface{}
}

Document model for inserting, updating an elastic search document.

func GetDocumentById

func GetDocumentById(index string, id string) (*Document, error)

type EsConnector

type EsConnector struct {
}

type EsService

type EsService interface {
	SearchWithKeyword(index string, query map[string]interface{})
	CreateNewIndex(index string) error
	CreateNewDocumentInIndex(index string, document *Document) (*Document, error)
	GetDocumentById(index string, id string) (*Document, error)
}

EsService interfaces all the methods related to elastic search.

type Rsa

type Rsa struct {
	PublicKeyPath  string
	PrivateKeyPath string
	PublicKey      interface{}
	PrivateKey     interface{}
}

Rsa is the struct to get the rsa keys used to generate and verify tokens from the environment variables

type SearchResult

type SearchResult struct {
	ID   interface{}
	Body interface{}
}

SearchResult is used essentially for mapping the search results gathered by SearchWithKeyword

func SearchWithKeyword

func SearchWithKeyword(index string, query *map[string]interface{}) []*SearchResult

SearchWithKeyword perform a search call through elastic search api.

Jump to

Keyboard shortcuts

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