Skip to content

Instantly share code, notes, and snippets.

View eranharel's full-sized avatar
🚵‍♂️
Typing...

Eran Harel eranharel

🚵‍♂️
Typing...
View GitHub Profile
@eranharel
eranharel / health-api-compact-response.py
Created August 5, 2019 13:51
go-sundheit query health API short response type
$ curl -i http://localhost:8080/admin/health.json?type=short
HTTP/1.1 200 OK
Content-Type: application/json
Date: Wed, 17 Jul 2019 12:54:18 GMT
Content-Length: 35
{
"resolve.example.com": "PASS"
}
@eranharel
eranharel / health-api-response.py
Created August 5, 2019 13:28
go-sundheit query health API
$ curl -i http://localhost:8080/admin/health.json
HTTP/1.1 200 OK
Content-Type: application/json
Date: Wed, 17 Jul 2019 12:54:20 GMT
Content-Length: 208
{
"resolve.example.com": {
"message": "[2] results were resolved",
"timestamp": "2019-07-17T15:54:18.225468956+03:00",
@eranharel
eranharel / register-health-endpoint.go
Created August 5, 2019 13:26
go-sundheit register health endpoint
http.Handle("/admin/health.json", healthhttp.HandleHealthJSON(h))
@eranharel
eranharel / register-health-checks-example.go
Created August 5, 2019 13:24
go-sundheit regiester built-in DNS check
import (
"time"
health "github.com/AppsFlyer/go-sundheit"
"github.com/AppsFlyer/go-sundheit/checks"
)
func registerHealthChecks() {
// create a new health instance
@eranharel
eranharel / health-as-ping.go
Created August 5, 2019 07:28
A naive Health API implemented as a ping endpoint
http.HandleFunc("/health", func(w http.ResponseWriter, request *http.Request) {
w.WriteHeader(200)
})
log.Fatal(http.ListenAndServe(":8080", nil))
@eranharel
eranharel / custom-dns-check-example.go
Created August 5, 2019 07:15
go-sundheit Custom DNS check Example
import (
"context"
"fmt"
"net"
"time"
"github.com/AppsFlyer/go-sundheit/checks"
"github.com/pkg/errors"
)
@eranharel
eranharel / custom-dns-check-example.go
Created August 4, 2019 14:39
Introducing go-sundheit code examples
import (
"context"
"fmt"
"net"
"time"
"github.com/AppsFlyer/go-sundheit/checks"
"github.com/pkg/errors"
)
(defn listenablefuture-handler
[lf on-success-func on-fail-func]
(Futures/addCallback
lf
(reify FutureCallback
(onSuccess [_ res]
(on-success-func res))
(onFailure [_ e]
(on-fail-func e))))
lf)
@eranharel
eranharel / FaviconHandler
Created October 14, 2014 07:43
A faviocon handler for Netty HTTP apps. Handles the cache headers and caches the icon bytes.
package com.outbrain.ob1k.server.netty;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONNECTION;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import static io.netty.handler.codec.http.HttpHeaders.Names.DATE;
import static io.netty.handler.codec.http.HttpHeaders.Names.IF_MODIFIED_SINCE;
import static io.netty.handler.codec.http.HttpHeaders.isKeepAlive;
import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST;
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_MODIFIED;
import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
@eranharel
eranharel / gist:6103369
Created July 29, 2013 10:12
Netty Graphite Client
package com.outbrain.gruffalo.publish;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler;