Skip to content

Latest commit

 

History

History
48 lines (37 loc) · 1.24 KB

README.md

File metadata and controls

48 lines (37 loc) · 1.24 KB

Skadi Go SDK

hack-fan/skadi is a cloud message center, you can send your message/job/command to it by several ways, Slack/Teams/Wechat etc... then your agent will get it, do anything you defined, return the result.

This is golang sdk for hack-fan/skadi, pull your jobs from skadi server.

Example

Prepare your TOKEN first.

There is several example agent by our team:

You can only start one worker per TOKEN.

package main

import (
    "context"
    "fmt"
    "os/signal"
    "syscall"

    "github.com/hack-fan/skadigo"
)

func handler(id,msg string) (string, error) {
    fmt.Printf("received command message: %s %s", id, msg)
    return msg,nil
}

func main() {
    // system signals - for graceful shutdown or restart
    ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
    defer stop()

    // skadi agent
    agent := skadigo.New("YOUR-TOKEN", "https://api.letserver.run", nil)
    agent.Start(ctx, handler, 0)
}

You can use the agent for sending messages anywhere.

    agent.SendInfo("Hello World")