aboutsummaryrefslogtreecommitdiffstats
path: root/skate/cmd/skate-dot
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-27 13:19:07 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-27 13:19:07 +0200
commit1756a09a3b5ed99d7fda27ce32632a0feb7fdc85 (patch)
tree41def30290a0e09fb1f2878a8253fde9ebacab4f /skate/cmd/skate-dot
parent9a07523ddb1b1afae67cf52e5ca264b755a8e494 (diff)
downloadrefcat-1756a09a3b5ed99d7fda27ce32632a0feb7fdc85.tar.gz
refcat-1756a09a3b5ed99d7fda27ce32632a0feb7fdc85.zip
remove unused/partially implemented skate-dot for now
Diffstat (limited to 'skate/cmd/skate-dot')
-rw-r--r--skate/cmd/skate-dot/main.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/skate/cmd/skate-dot/main.go b/skate/cmd/skate-dot/main.go
deleted file mode 100644
index 573209e..0000000
--- a/skate/cmd/skate-dot/main.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// [wip] skate-dot generates dot files from inbound and outbound citation
-// links. Just a demo, replacement for a couple python scripts. We want things
-// like: https://git.io/JObzq.
-package main
-
-import (
- "context"
- "flag"
- "fmt"
- "io"
- "log"
- "os"
-
- "github.com/elastic/go-elasticsearch/esapi"
- elasticsearch "github.com/elastic/go-elasticsearch/v7"
-)
-
-var (
- es = flag.String("es", "http://localhost:9200", "elasticsearch holding fatcat_ref index")
- index = flag.String("x", "fatcat_ref_v01", "index name")
- fatcat = flag.String("f", "https://api.fatcat.wiki/v0", "fatcat api")
- ident = flag.String("i", "2kw3xjf2cbcmdlm3ihkoz2t4lu", "release ident")
-)
-
-func main() {
- flag.Parse()
- cfg := elasticsearch.Config{Addresses: []string{*es}}
- es, err := elasticsearch.NewClient(cfg)
- if err != nil {
- log.Fatal(err)
- }
- client := &Client{
- Api: *fatcat,
- Es: es,
- Index: *index,
- }
- client.Outbound(*ident)
-}
-
-// A client for fatcat and elasticsearch.
-type Client struct {
- Api string
- Es *elasticsearch.Client
- Index string
-}
-
-func (c *Client) String() string {
- info, _ := c.Es.Info()
- return fmt.Sprintf("%s %s (%s) %s", c.Api, info, elasticsearch.Version, c.Index)
-}
-
-func (c *Client) Inbound(ident string) []string {
- resp, err := c.Es.Search(
- c.Es.Search.WithContext(context.Background()),
- c.Es.Search.WithIndex(c.Index),
- )
- if err != nil {
- log.Fatal(err)
- }
- io.Copy(os.Stdout, resp.Body)
- return nil
-}
-
-func (c *Client) Outbound(ident string) []string {
- req := &esapi.SearchRequest{
- Query: fmt.Sprintf("source_release_ident:%s", ident),
- }
- resp, err := req.Do(context.Background(), c.Es)
- if err != nil {
- log.Fatal(err)
- }
- io.Copy(os.Stdout, resp.Body)
- return nil
-}