-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
stefink
committed
Jun 27, 2022
1 parent
be7c65e
commit 5653e3d
Showing
9 changed files
with
82 additions
and
59 deletions.
There are no files selected for viewing
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
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
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
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
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package integrations | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
) | ||
|
||
func loghandler(w http.ResponseWriter, r *http.Request) { | ||
if r.URL.Path != "/log" { | ||
http.Error(w, "404 not found.", http.StatusNotFound) | ||
return | ||
} | ||
if r.Method != "POST" { | ||
fmt.Fprintf(w, "Only POST method is supported") | ||
return | ||
} | ||
body, err := ioutil.ReadAll(r.Body) | ||
if err != nil { | ||
fmt.Fprintf(w, "err : %v", err) | ||
} | ||
w.Header().Set("Content-Type", "application/json") | ||
config, err := ReadLogConfig("src/conf/datasage.yaml") | ||
if err != nil { | ||
fmt.Fprintf(w, `{status: "not ok", "error": %v}`, err) | ||
return | ||
} | ||
config.StreamLogToAll(string(body)) | ||
if err != nil { | ||
fmt.Fprintf(w, `{status: "not ok", "error": %v}`, err) | ||
return | ||
} | ||
fmt.Fprintf(w, `{status : "ok"}`) | ||
} | ||
func RunServer() { | ||
|
||
http.HandleFunc("/log", loghandler) | ||
fmt.Printf("HTTP Server listening on :8080\n") | ||
fmt.Printf("Send logs to 127.0.0.1:8080/log endpoint\n") | ||
if err := http.ListenAndServe(":8080", nil); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
package integrations | ||
|
||
func (intg Integrations) StreamLogToAll(Log string) { | ||
StreamLogToGRPC(Log, intg.Rpc) | ||
StreamLogToKafka(Log, intg.Kafka) | ||
import "log" | ||
|
||
func (intg Integrations) StreamLogToAll(Log string) error { | ||
err := StreamLogToGRPC(Log, intg.Rpc) | ||
if err != nil { | ||
log.Printf("err: %s\n", err) | ||
} | ||
err = StreamLogToKafka(Log, intg.Kafka) | ||
if err != nil { | ||
log.Printf("err: %s\n", err) | ||
} | ||
return nil | ||
} |
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