spiderman

package module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2022 License: MIT Imports: 7 Imported by: 0

README

Installation

go get github.com/nanguohuakai/spiderman


import "github.com/nanguohuakai/spiderman"

https://pkg.go.dev/github.com/nanguohuakai/spiderman

Documentation

Overview

Package spiderman 为集成 Pizza, Sso, Schedule, Alert, Msg, Gohr, Comment等服务的客户端

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spiderman

type Spiderman interface {
	Alert(conf dto.AlertConf) (alert.AlertInterface, error)             //Alert 消息服务
	Pizza(conf dto.PizzaConf) (pizza.PizzaInterface, error)             //Pizza pizza服务
	Schedule(conf dto.ScheduleConf) (schedule.ScheduleInterface, error) //Schedule 定时任务调度服务
	Sso(conf dto.SsoConf) (sso.SsoInterface, error)                     //Sso sso服务
	GoHr(conf dto.GoHrConf) (gohr.GoHrInterface, error)                 //GoHr gohr服务
}

Spiderman support pipelining using the Pizza, Sso, Schedule and Alert methods

func NewSpiderman

func NewSpiderman(conf dto.AppConf) (Spiderman, error)

The NewSpiderman interface is the primary interface for working with Spiderman

Example

NewSpiderman

//app conf
conf := dto.AppConf{
	ServiceName: "test",
	Token:       "example",
}
s, _ := NewSpiderman(conf)
fmt.Println(s)
Output:

type SpidermanClient

type SpidermanClient struct {
	AppConf dto.AppConf
}

func (*SpidermanClient) Alert

func (receiver *SpidermanClient) Alert(conf dto.AlertConf) (alert.AlertInterface, error)

Alert store alert service

Example
conf := dto.AppConf{
	ServiceName: "test",
	Token:       "example",
}
spiderman, _ := NewSpiderman(conf)

alertConf := dto.AlertConf{
	BaseUri: "127.0.0.1",
	Level:   "warn",
	Env:     "test",
}

alert, _ := spiderman.Alert(alertConf)
fmt.Println(alert)
Output:

func (*SpidermanClient) GoHr added in v0.1.2

func (receiver *SpidermanClient) GoHr(conf dto.GoHrConf) (gohr.GoHrInterface, error)

GoHr store GoHr service

func (*SpidermanClient) Pizza

func (receiver *SpidermanClient) Pizza(conf dto.PizzaConf) (pizza.PizzaInterface, error)

Pizza store pizza service

Example
conf := dto.AppConf{
	ServiceName: "test",
	Token:       "example",
}
spiderman, _ := NewSpiderman(conf)

pizzaConf := dto.PizzaConf{
	BaseUri: "127.0.0.1",
}

pizza, _ := spiderman.Pizza(pizzaConf)
fmt.Println(pizza)
Output:

func (*SpidermanClient) Schedule

func (receiver *SpidermanClient) Schedule(conf dto.ScheduleConf) (schedule.ScheduleInterface, error)

Schedule store schedule service

Example
conf := dto.AppConf{
	ServiceName: "test",
	Token:       "example",
}
spiderman, _ := NewSpiderman(conf)

schedule, _ := spiderman.Schedule(dto.ScheduleConf{
	BaseUri:     "http://127.0.0.1:8081",
	CallbackUri: "http://127.0.0.1:8080",
})
fmt.Println(schedule)
Output:

func (*SpidermanClient) Sso

func (receiver *SpidermanClient) Sso(conf dto.SsoConf) (sso.SsoInterface, error)

Sso store sso service

Example
conf := dto.AppConf{
	ServiceName: "test",
	Token:       "example",
}
spiderman, _ := NewSpiderman(conf)
ssoConf := dto.SsoConf{
	BaseUri: "127.0.0.1",
	AppId:   "test",
	AppKey:  "test1",
}
sso, _ := spiderman.Sso(ssoConf)
fmt.Println(sso)
Output:

Directories

Path Synopsis
core
schedule
使用 RegisterCorn 和 RegisterCornTime 之前必须先使用 RegisterHandler 注册路由 使用 RegisterCorn 和 RegisterCornTime 里有判断是否已经使用 RegisterHandler 注册路由的强制校验 保证调用 RegisterHandler 和调用 RegisterCorn 或 RegisterCornTime 的 Schedule 为同一个实例化,否则报错 conf := dto.AppConf{ ServiceName: "test", Token: "example", } spiderman, _ := spiderman2.NewSpiderman(conf) schedule,_ := spiderman.Schedule(dto.ScheduleConf{ BaseUri: "http://127.0.0.1:8081", CallbackUri: "http://127.0.0.1:8080", }) var r *gin.Engine _ = schedule.RegisterHandler(r, JobHandelFunc, "/test/path") _= schedule.RegisterCorn(dto.ScheduleRegisterInput{ ScheduleId: "test-talent", ScheduleName: "ttttt", CallbackParams: nil, Value: "*\/1 * * * *", })
使用 RegisterCorn 和 RegisterCornTime 之前必须先使用 RegisterHandler 注册路由 使用 RegisterCorn 和 RegisterCornTime 里有判断是否已经使用 RegisterHandler 注册路由的强制校验 保证调用 RegisterHandler 和调用 RegisterCorn 或 RegisterCornTime 的 Schedule 为同一个实例化,否则报错 conf := dto.AppConf{ ServiceName: "test", Token: "example", } spiderman, _ := spiderman2.NewSpiderman(conf) schedule,_ := spiderman.Schedule(dto.ScheduleConf{ BaseUri: "http://127.0.0.1:8081", CallbackUri: "http://127.0.0.1:8080", }) var r *gin.Engine _ = schedule.RegisterHandler(r, JobHandelFunc, "/test/path") _= schedule.RegisterCorn(dto.ScheduleRegisterInput{ ScheduleId: "test-talent", ScheduleName: "ttttt", CallbackParams: nil, Value: "*\/1 * * * *", })
sso
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL