Giter VIP home page Giter VIP logo

hello-cloud-functions's Introduction

Hello Cloud Functions

[] HttpFunction [x] BackgroundFunction [x] RawBackgroundFunction

Development

Requisitos:

  • Java 11
  • Maven
  • Docker

Spring

Elastic

docker run -d --name elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.10.1

Mapping

curl --location --request PUT 'localhost:9200/merchants' \
--header 'Content-Type: application/json' \
--data-raw '{
    "mappings": {
        "properties": {
            "name": {
                "type": "text"
            },
            "location": {
                "type": "geo_point"
            },
            "payment_options": {
                "type": "keyword"
            },
            "category": {
                "type": "keyword"
            },
            "created_at": {
                "type": "date",
                "format": "epoch_millis"
            }
        }
    }
}'

Executar a Function local

./scripts/start-local.sh <PROJECT>

Message Payload

Base64 Message Payload

echo -n '{
    "id":"MERCHANT_ID",
    "op":"UPSERT|DELETE",
    "data":{
      ...
    }
}' | base64

Trigger na Function

cd scripts

./trigger.sh upsert.json

./trigger.sh delete.json

Ou

curl localhost:8080 \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
        "context": {
          "eventId":"1144231683168617",
          "timestamp":"2020-05-06T07:33:34.556Z",
          "eventType":"google.pubsub.topic.publish",
          "resource":{
            "service":"pubsub.googleapis.com",
            "name":"projects/sample-project/topics/gcf-test",
            "type":"type.googleapis.com/google.pubsub.v1.PubsubMessage"
          }
        },
        "data": {
          "@type": "type.googleapis.com/google.pubsub.v1.PubsubMessage",
          "attributes": {
             "attr1":"attr1-value"
          },
          "data": "BASE64_PAYLOAD"
        }
      }'
curl --location --request GET 'localhost:9200/merchants/_mappings'
curl localhost:9200/merchants/_doc/1

hello-cloud-functions's People

Contributors

andrelugomes avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.