kubeless

package module
v0.0.0-...-9db3ab3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: BSD-2-Clause Imports: 15 Imported by: 0

README

publication function

A Golang-based Kubeless function to deploy in a Kubernetes cluster.

Dependencies

Deploy the function

$_> zip pubfn.zip *.go go.mod
$_> kubeless function deploy \
pubfn --runtime go1.13 --from-file pubfn.zip --handler publication.Handler
--dependencies go.mod --namespace dictybase

  • check the status of function

$_> kubeless function ls -n dictybase

Add Ingress

Create a YAML file like this GKE Ingress Dev example.

$_> kubectl apply -f gke-ingress-dev.yaml -n dictybase

Endpoints

It will be available through the mapped host, for example through betafunc.dictybase.org assuming the above function.

GET /publications/{pubmed-id} - Information about a publication with given Pubmed ID.

$_> curl -k https://betafunc.dictybase.local/publications/30048658

The expected output will be in the following structure

{
  "links": {
    "self": "https://betafunc.dictybase.local/publications/16769729"
  },
  "data": {
    "attributes": {
      "authors": [
        {
          "initials": "A",
          "full_name": "Kortholt A",
          "last_name": "Kortholt",
          "first_name": "Arjan"
        },
        {
          "initials": "H",
          "full_name": "Rehmann H",
          "last_name": "Rehmann",
          "first_name": "Holger"
        },
        {
          "initials": "H",
          "full_name": "Kae H",
          "last_name": "Kae",
          "first_name": "Helmut"
        },
        {
          "initials": "L",
          "full_name": "Bosgraaf L",
          "last_name": "Bosgraaf",
          "first_name": "Leonard"
        },
        {
          "initials": "I",
          "full_name": "Keizer-Gunnink I",
          "last_name": "Keizer-Gunnink",
          "first_name": "Ineke"
        },
        {
          "initials": "G",
          "full_name": "Weeks G",
          "last_name": "Weeks",
          "first_name": "Gerald"
        },
        {
          "initials": "A",
          "full_name": "Wittinghofer A",
          "last_name": "Wittinghofer",
          "first_name": "Alfred"
        },
        {
          "initials": "PJ",
          "full_name": "Van Haastert PJ",
          "last_name": "Van Haastert",
          "first_name": "Peter J M"
        }
      ],
      "publication_date": "2006-06-12",
      "issue": 1341878,
      "pub_type": "Research Support, Non-U.S. Gov't",
      "status": "published",
      "source": "MED",
      "title": "Characterization of the GbpD-activated Rap1 pathway...",
      "abstract": "The regulation of cell polarity...",
      "doi": "10.1074/jbc.m600804200",
      "full_text_url": "https://doi.org/10.1074/jbc.M600804200",
      "pubmed_url": "https://pubmed.gov/16769729",
      "journal": "The Journal of biological chemistry",
      "issn": "0021-9258",
      "page": "23367-23376",
      "pubmed": "16769729"
    },
    "id": "16769729",
    "type": "publications"
  }
}

Documentation

Index

Constants

View Source
const REDIS_KEY = "PUBLICATION_KEY"

Variables

This section is empty.

Functions

func Handler

func Handler(event functions.Event, ctx functions.Context) (string, error)

func JSONAPIError

func JSONAPIError(err error) (string, int, error)

JSONAPIError generate JSONAPI formatted http error from an error object

Types

type Author

type Author struct {
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name"`
	FullName  string `json:"full_name"`
	Initials  string `json:"initials"`
}

type Cacher

type Cacher interface {
	Get(string) ([]byte, error)
	Set(string, []byte, time.Duration) error
	Delete(string) error
	IsExist(string) bool
	ClearAll(string) error
}

func NewRedisCache

func NewRedisCache(addr string) Cacher

func NewRedisReplicationCache

func NewRedisReplicationCache(master, slave string) Cacher

type EuroPMC

type EuroPMC struct {
	HitCount       int64  `json:"hitCount"`
	NextCursorMark string `json:"nextCursorMark"`
	Request        struct {
		CursorMark string `json:"cursorMark"`
		PageSize   int64  `json:"pageSize"`
		Query      string `json:"query"`
		ResultType string `json:"resultType"`
		Sort       string `json:"sort"`
		Synonym    bool   `json:"synonym"`
	} `json:"request"`
	ResultList struct {
		Result []struct {
			AbstractText string `json:"abstractText"`
			Affiliation  string `json:"affiliation"`
			AuthMan      string `json:"authMan"`
			AuthorList   struct {
				Author []struct {
					Affiliation string `json:"affiliation"`
					FirstName   string `json:"firstName"`
					FullName    string `json:"fullName"`
					Initials    string `json:"initials"`
					LastName    string `json:"lastName"`
				} `json:"author"`
			} `json:"authorList"`
			AuthorString              string `json:"authorString"`
			CitedByCount              int64  `json:"citedByCount"`
			DateOfCreation            string `json:"dateOfCreation"`
			DateOfRevision            string `json:"dateOfRevision"`
			Doi                       string `json:"doi"`
			ElectronicPublicationDate string `json:"electronicPublicationDate"`
			EpmcAuthMan               string `json:"epmcAuthMan"`
			FirstPublicationDate      string `json:"firstPublicationDate"`
			FullTextURLList           struct {
				FullTextURL []struct {
					Availability     string `json:"availability"`
					AvailabilityCode string `json:"availabilityCode"`
					DocumentStyle    string `json:"documentStyle"`
					Site             string `json:"site"`
					URL              string `json:"url"`
				} `json:"fullTextUrl"`
			} `json:"fullTextUrlList"`
			HasBook               string `json:"hasBook"`
			HasDBCrossReferences  string `json:"hasDbCrossReferences"`
			HasLabsLinks          string `json:"hasLabsLinks"`
			HasPDF                string `json:"hasPDF"`
			HasReferences         string `json:"hasReferences"`
			HasTMAccessionNumbers string `json:"hasTMAccessionNumbers"`
			HasTextMinedTerms     string `json:"hasTextMinedTerms"`
			ID                    string `json:"id"`
			InEPMC                string `json:"inEPMC"`
			InPMC                 string `json:"inPMC"`
			IsOpenAccess          string `json:"isOpenAccess"`
			JournalInfo           struct {
				DateOfPublication string `json:"dateOfPublication"`
				Journal           struct {
					Essn                string `json:"essn"`
					Isoabbreviation     string `json:"isoabbreviation"`
					Issn                string `json:"issn"`
					MedlineAbbreviation string `json:"medlineAbbreviation"`
					Nlmid               string `json:"nlmid"`
					Title               string `json:"title"`
				} `json:"journal"`
				JournalIssueID       int64  `json:"journalIssueId"`
				MonthOfPublication   int64  `json:"monthOfPublication"`
				PrintPublicationDate string `json:"printPublicationDate"`
				YearOfPublication    int64  `json:"yearOfPublication"`
				Issue                string `json:"issue"`
				Volume               string `json:"volume"`
			} `json:"journalInfo"`
			KeywordList struct {
				Keyword []string `json:"keyword"`
			} `json:"keywordList"`
			Language    string `json:"language"`
			NihAuthMan  string `json:"nihAuthMan"`
			PageInfo    string `json:"pageInfo"`
			Pmid        string `json:"pmid"`
			PubModel    string `json:"pubModel"`
			PubTypeList struct {
				PubType []string `json:"pubType"`
			} `json:"pubTypeList"`
			PubYear string `json:"pubYear"`
			Source  string `json:"source"`
			Title   string `json:"title"`
		} `json:"result"`
	} `json:"resultList"`
	Version string `json:"version"`
}
type Links struct {
	Self string `json:"self"`
}

type PubData

type PubData struct {
	Type       string       `json:"type"`
	ID         string       `json:"id"`
	Attributes *Publication `json:"attributes"`
}

type PubJsonAPI

type PubJsonAPI struct {
	Data  *PubData `json:"data"`
	Links *Links   `json:"links"`
}

type Publication

type Publication struct {
	Abstract       string    `json:"abstract"`
	Doi            string    `json:"doi,omitempty"`
	FullTextURL    string    `json:"full_text_url,omitempty"`
	PubmedURL      string    `json:"pubmed_url"`
	Journal        string    `json:"journal"`
	Issn           string    `json:"issn,omitempty"`
	Page           string    `json:"page,omitempty"`
	Pubmed         string    `json:"pubmed"`
	Title          string    `json:"title"`
	Source         string    `json:"source"`
	Status         string    `json:"status"`
	PubType        string    `json:"pub_type"`
	Issue          string    `json:"issue"`
	Volume         string    `json:"volume"`
	JournalIssueId int64     `json:"journalIssueId,omitempty"`
	PublishedDate  string    `json:"publication_date"`
	Authors        []*Author `json:"authors"`
}

func EuroPMC2Pub

func EuroPMC2Pub(pmc *EuroPMC) *Publication

type RedisCache

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

func (*RedisCache) ClearAll

func (r *RedisCache) ClearAll(prefix string) error

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string) error

func (*RedisCache) Get

func (r *RedisCache) Get(key string) ([]byte, error)

func (*RedisCache) IsExist

func (r *RedisCache) IsExist(key string) bool

func (*RedisCache) Set

func (r *RedisCache) Set(key string, val []byte, t time.Duration) error

type RedisReplicationCache

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

func (*RedisReplicationCache) ClearAll

func (r *RedisReplicationCache) ClearAll(prefix string) error

func (*RedisReplicationCache) Delete

func (r *RedisReplicationCache) Delete(key string) error

func (*RedisReplicationCache) Get

func (r *RedisReplicationCache) Get(key string) ([]byte, error)

func (*RedisReplicationCache) IsExist

func (r *RedisReplicationCache) IsExist(key string) bool

func (*RedisReplicationCache) Set

func (r *RedisReplicationCache) Set(key string, val []byte, t time.Duration) error

Jump to

Keyboard shortcuts

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