This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/confluentinc/confluent-kafka-go/kafka" | |
) | |
func main() { | |
kafkaBroker := "localhost:9092" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
"time" | |
"github.com/confluentinc/confluent-kafka-go/kafka" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
kafkaBroker := "localhost:9092" | |
p, _ := kafka.NewProducer(&kafka.ConfigMap{"bootstrap.servers": kafkaBroker}) | |
topic := "bar" | |
partition := kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny} | |
msg := &kafka.Message{TopicPartition: partition, Key: []byte("hello"), Value: []byte("world")} | |
p.Produce(msg, nil) | |
fmt.Println("done...") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/confluentinc/confluent-kafka-go/kafka" | |
) | |
func main() { | |
kafkaBroker := "foo:9092" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
kafkaBroker := "foo:9092" | |
p, err := kafka.NewProducer(&kafka.ConfigMap{"bootstrap.servers": kafkaBroker}) | |
if err != nil { | |
fmt.Println("producer creation failed ", err.Error()) | |
return | |
} | |
topic := "bar" | |
partition := kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM fnproject/fn-java-fdk-build:jdk9-1.0.75 as build-stage | |
WORKDIR /function | |
ENV MAVEN_OPTS -Dhttp.proxyHost= -Dhttp.proxyPort= -Dhttps.proxyHost= -Dhttps.proxyPort= -Dhttp.nonProxyHosts= -Dmaven.repo.local=/usr/share/maven/ref/repository | |
ADD pom.xml /function/pom.xml | |
RUN ["mvn", "package", "dependency:copy-dependencies", "-DincludeScope=runtime", "-DskipTests=true", "-Dmdep.prependGroupId=true", "-DoutputDirectory=target", "--fail-never"]' | |
ARG TENSORFLOW_VERSION=1.12.0 | |
RUN echo "using tensorflow version " $TENSORFLOW_VERSION | |
RUN curl -LJO https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-$TENSORFLOW_VERSION.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"time" | |
"github.com/oracle/oci-go-sdk/common" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
var notification newReleaseNotification | |
json.NewDecoder(strings.NewReader(payload)).Decode(¬ification) | |
err := tweet(notification.Details(), fnCtx.Config()["twitter_consumerkey"], fnCtx.Config()["twitter_consumersecret"], fnCtx.Config()["twitter_accesstoken"], fnCtx.Config()["twitter_accesstokensecret"]) | |
if err != nil { | |
fdk.WriteStatus(out, 500) | |
prob := "Could not tweet new release details due to " + err.Error() | |
log.Println(prob) | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
func matchSignature(signature, key, payload string) bool { | |
mac := hmac.New(sha1.New, []byte(key)) | |
mac.Write([]byte(payload)) | |
expectedHMAC := mac.Sum(nil) | |
//signature format is sha1=foobarred | |
githubHMAC, _ := hex.DecodeString(strings.Split(signature, "=")[1]) | |
match := hmac.Equal(githubHMAC, expectedHMAC) | |
return match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
signatureFromGithub := fnCtx.Header().Get("X-Hub-Signature") | |
if !matchSignature(signatureFromGithub, fnCtx.Config()["github_webhook_secret"], payload) { | |
log.Println("Signature did not match. Webhook was not invoked by Github") | |
return | |
} | |
... |