code stringlengths 1 1.05M | repo_name stringlengths 6 83 | path stringlengths 3 242 | language stringclasses 222
values | license stringclasses 20
values | size int64 1 1.05M |
|---|---|---|---|---|---|
package service
import (
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
models2 "github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func ... | 2302_79757062/crawlab | core/models/service/token_service.go | Go | bsd-3-clause | 1,240 |
package service
import (
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
models2 "github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func ... | 2302_79757062/crawlab | core/models/service/user_role_service.go | Go | bsd-3-clause | 1,703 |
package service
import (
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
models2 "github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func ... | 2302_79757062/crawlab | core/models/service/user_service.go | Go | bsd-3-clause | 1,743 |
package service
import (
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
models2 "github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func ... | 2302_79757062/crawlab | core/models/service/variable_service.go | Go | bsd-3-clause | 1,465 |
package config
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/utils"
"github.com/spf13/viper"
)
type Config entity.NodeInfo
type Options struct {
Key string
Name string
IsMaster bool
AuthKey strin... | 2302_79757062/crawlab | core/node/config/config.go | Go | bsd-3-clause | 1,478 |
package config
import (
"encoding/json"
"github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/utils"
"github.com/crawlab-team/crawlab/trace"
"os"
"path"
)
type Service struct {
cfg *... | 2302_79757062/crawlab | core/node/config/config_service.go | Go | bsd-3-clause | 2,618 |
package config
import (
"github.com/crawlab-team/crawlab/core/interfaces"
)
type Option func(svc interfaces.NodeConfigService)
func WithConfigPath(path string) Option {
return func(svc interfaces.NodeConfigService) {
svc.SetConfigPath(path)
}
}
| 2302_79757062/crawlab | core/node/config/options.go | Go | bsd-3-clause | 253 |
package service
import (
"github.com/apex/log"
config2 "github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/grpc/server"
"github.com/craw... | 2302_79757062/crawlab | core/node/service/master_service.go | Go | bsd-3-clause | 9,410 |
package service
import (
"errors"
"github.com/apex/log"
"github.com/cenkalti/backoff/v4"
config2 "github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/grpc/server"
"github.com/crawlab... | 2302_79757062/crawlab | core/node/service/master_service_v2.go | Go | bsd-3-clause | 9,601 |
package service
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"time"
)
type Option func(svc interfaces.NodeService)
func WithConfigPath(path string) Option {
return func(svc interfaces.NodeService) {
svc.SetConfigPath(path)
}
}
func WithAddress(address interfaces.Address) Option {
return func(sv... | 2302_79757062/crawlab | core/node/service/options.go | Go | bsd-3-clause | 963 |
package service
import (
"context"
"encoding/json"
"github.com/apex/log"
config2 "github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/grpc/client"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/c... | 2302_79757062/crawlab | core/node/service/worker_service.go | Go | bsd-3-clause | 5,491 |
package service
import (
"context"
"encoding/json"
"github.com/apex/log"
config2 "github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/grpc/client"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/c... | 2302_79757062/crawlab | core/node/service/worker_service_v2.go | Go | bsd-3-clause | 5,095 |
package test
import (
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/interfaces"
service2 "github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/node/service"
"github.com/crawlab-team/crawlab/core/utils"
"github.com/spf13/viper"
"go.uber.... | 2302_79757062/crawlab | core/node/test/base.go | Go | bsd-3-clause | 5,561 |
package notification
const (
TypeMail = "mail"
TypeMobile = "mobile"
)
const (
SettingsColName = "notification_settings"
)
| 2302_79757062/crawlab | core/notification/constants.go | Go | bsd-3-clause | 130 |
package notification
import (
"errors"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/matcornic/hermes/v2"
"gopkg.in/gomail.v2"
"net/mail"
"runtime/debug"
"strconv"
"strings"
)
func SendMail(m *models.NotificationSettingMail, to, cc, title, content string) error {
// ... | 2302_79757062/crawlab | core/notification/mail.go | Go | bsd-3-clause | 4,485 |
package notification
import "github.com/matcornic/hermes/v2"
type MailTheme interface {
hermes.Theme
GetStyle() string
}
| 2302_79757062/crawlab | core/notification/mail_theme.go | Go | bsd-3-clause | 125 |
package notification
// MailThemeFlat is a theme
type MailThemeFlat struct{}
// Name returns the name of the flat theme
func (dt *MailThemeFlat) Name() string {
return "flat"
}
// HTMLTemplate returns a Golang template that will generate an HTML email.
func (dt *MailThemeFlat) HTMLTemplate() string {
return `
<!DO... | 2302_79757062/crawlab | core/notification/mail_theme_flat.go | Go | bsd-3-clause | 10,192 |
package notification
import (
"errors"
"github.com/crawlab-team/crawlab/trace"
"github.com/imroc/req"
"strings"
)
type ResBody struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
}
func SendMobileNotification(webhook string, title string, content string) error {
// request header
header :... | 2302_79757062/crawlab | core/notification/mobile.go | Go | bsd-3-clause | 1,170 |
package notification
import "go.mongodb.org/mongo-driver/bson/primitive"
type NotificationSetting struct {
Id primitive.ObjectID `json:"_id" bson:"_id"`
Type string `json:"type" bson:"type"`
Name string `json:"name" bson:"name"`
Description strin... | 2302_79757062/crawlab | core/notification/models.go | Go | bsd-3-clause | 1,664 |
package notification
import "go.mongodb.org/mongo-driver/bson/primitive"
type SendPayload struct {
TaskId primitive.ObjectID `json:"task_id"`
Data string `json:"data"`
}
| 2302_79757062/crawlab | core/notification/payload.go | Go | bsd-3-clause | 188 |
package notification
import (
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/utils"
mongo2 "githu... | 2302_79757062/crawlab | core/notification/service.go | Go | bsd-3-clause | 10,340 |
package notification
import (
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
mongo2 "github.com/crawlab-team/crawlab/db/mongo"
parser "... | 2302_79757062/crawlab | core/notification/service_v2.go | Go | bsd-3-clause | 10,100 |
package process
import (
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/sys_exec"
"github.com/crawlab-team/crawlab/trace"
"math/rand"
"os/exec"
"time"
)
const (
SignalCreate = iota
SignalStart
Signa... | 2302_79757062/crawlab | core/process/daemon.go | Go | bsd-3-clause | 3,196 |
package process
import (
"github.com/crawlab-team/crawlab/trace"
"os/exec"
"regexp"
"runtime"
"strings"
)
var pidRegexp, _ = regexp.Compile("(?:^|\\s+)\\d+(?:$|\\s+)")
func ProcessIdExists(id int) (ok bool) {
lines, err := ListProcess(string(rune(id)))
if err != nil {
return false
}
for _, line := range l... | 2302_79757062/crawlab | core/process/manage.go | Go | bsd-3-clause | 1,267 |
package process
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"time"
)
type DaemonOption func(d interfaces.ProcessDaemon)
func WithDaemonMaxErrors(maxErrors int) DaemonOption {
return func(d interfaces.ProcessDaemon) {
d.SetMaxErrors(maxErrors)
}
}
func WithExitTimeout(timeout time.Duration) Daem... | 2302_79757062/crawlab | core/process/options.go | Go | bsd-3-clause | 380 |
package result
import "go.mongodb.org/mongo-driver/bson/primitive"
type Option func(opts *Options)
type Options struct {
registryKey string // registry key
SpiderId primitive.ObjectID // data source id
}
func WithRegistryKey(key string) Option {
return func(opts *Options) {
opts.registryKey = ke... | 2302_79757062/crawlab | core/result/options.go | Go | bsd-3-clause | 327 |
package result
import (
"fmt"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/trace"
"go.mongodb.org/mongo-driver/bson/primi... | 2302_79757062/crawlab | core/result/service.go | Go | bsd-3-clause | 1,962 |
package result
import (
"github.com/crawlab-team/crawlab/trace"
"time"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/c... | 2302_79757062/crawlab | core/result/service_mongo.go | Go | bsd-3-clause | 3,934 |
package result
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"sync"
)
type ServiceRegistry struct {
// internals
services sync.Map
}
func (r *ServiceRegistry) Register(key string, fn interfaces.ResultServiceRegistryFn) {
r.services.Store(key, fn)
}
func (r *ServiceRegistry) Unregister(key string) ... | 2302_79757062/crawlab | core/result/service_registry.go | Go | bsd-3-clause | 919 |
package test
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/delegate"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/result"
"github.com/crawlab-team/crawlab/... | 2302_79757062/crawlab | core/result/test/base.go | Go | bsd-3-clause | 1,400 |
package routes
import (
"github.com/crawlab-team/crawlab/core/middlewares"
"github.com/gin-gonic/gin"
)
type RouterGroups struct {
AuthGroup *gin.RouterGroup
AnonymousGroup *gin.RouterGroup
FilerGroup *gin.RouterGroup
}
func NewRouterGroups(app *gin.Engine) (groups *RouterGroups) {
return &RouterGroup... | 2302_79757062/crawlab | core/routes/group.go | Go | bsd-3-clause | 518 |
package routes
import (
"fmt"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/controllers"
"github.com/gin-gonic/gin"
"net/http"
"path"
)
type RouterServiceInterface interface {
RegisterControllerToGroup(group *gin.RouterGroup, basePath string, ctr controllers.ListController)
RegisterHandlerToGrou... | 2302_79757062/crawlab | core/routes/router.go | Go | bsd-3-clause | 5,913 |
package schedule
import (
"fmt"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/trace"
"github.com/robfig/cron/v3"
"strings"
)
type Logger struct {
}
func (l *Logger) Info(msg string, keysAndValues ...interface{}) {
p := l.getPlaceholder(len(keysAndValues))
log.Infof(fmt.Sprintf("cron: %s %s", msg, p),... | 2302_79757062/crawlab | core/schedule/logger.go | Go | bsd-3-clause | 765 |
package schedule
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"time"
)
type Option func(svc interfaces.ScheduleService)
func WithConfigPath(path string) Option {
return func(svc interfaces.ScheduleService) {
svc.SetConfigPath(path)
}
}
func WithLocation(loc *time.Location) Option {
return func(... | 2302_79757062/crawlab | core/schedule/options.go | Go | bsd-3-clause | 718 |
package schedule
import (
"github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/delegate"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/c... | 2302_79757062/crawlab | core/schedule/service.go | Go | bsd-3-clause | 5,786 |
package schedule
import (
"github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/spider/admin"
"github.com/crawlab-team/crawlab... | 2302_79757062/crawlab | core/schedule/service_v2.go | Go | bsd-3-clause | 5,601 |
package test
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/delegate"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/schedule"
"go.uber.org/dig"
"testing"
)
... | 2302_79757062/crawlab | core/schedule/test/base.go | Go | bsd-3-clause | 1,881 |
package admin
import "github.com/crawlab-team/crawlab/core/interfaces"
type Option func(svc interfaces.SpiderAdminService)
func WithConfigPath(path string) Option {
return func(svc interfaces.SpiderAdminService) {
svc.SetConfigPath(path)
}
}
| 2302_79757062/crawlab | core/spider/admin/options.go | Go | bsd-3-clause | 249 |
package admin
import (
"context"
"github.com/apex/log"
config2 "github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.... | 2302_79757062/crawlab | core/spider/admin/service.go | Go | bsd-3-clause | 7,923 |
package admin
import (
"context"
"github.com/apex/log"
config2 "github.com/crawlab-team/crawlab/core/config"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"git... | 2302_79757062/crawlab | core/spider/admin/service_v2.go | Go | bsd-3-clause | 7,469 |
package stats
import "github.com/crawlab-team/crawlab/core/interfaces"
type Option func(svc interfaces.StatsService)
| 2302_79757062/crawlab | core/stats/options.go | Go | bsd-3-clause | 119 |
package stats
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
mongo2 "go.mongodb.org/mongo-driver/mongo"
)
type Service struct {... | 2302_79757062/crawlab | core/stats/service.go | Go | bsd-3-clause | 7,099 |
package sys_exec
import (
"bufio"
"github.com/crawlab-team/crawlab/trace"
"github.com/shirou/gopsutil/process"
"os/exec"
"time"
)
type KillProcessOptions struct {
Timeout time.Duration
Force bool
}
func KillProcess(cmd *exec.Cmd, opts *KillProcessOptions) error {
// process
p, err := process.NewProcess(in... | 2302_79757062/crawlab | core/sys_exec/sys_exec.go | Go | bsd-3-clause | 1,837 |
//go:build darwin
// +build darwin
package sys_exec
import (
"os/exec"
"syscall"
)
func BuildCmd(cmdStr string) *exec.Cmd {
return exec.Command("sh", "-c", cmdStr)
}
func SetPgid(cmd *exec.Cmd) {
if cmd == nil {
return
}
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
} ... | 2302_79757062/crawlab | core/sys_exec/sys_exec_darwin.go | Go | bsd-3-clause | 365 |
//go:build linux
// +build linux
package sys_exec
import (
"os/exec"
"syscall"
)
func BuildCmd(cmdStr string) *exec.Cmd {
return exec.Command("sh", "-c", cmdStr)
}
func SetPgid(cmd *exec.Cmd) {
if cmd == nil {
return
}
if cmd.SysProcAttr == nil {
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
} el... | 2302_79757062/crawlab | core/sys_exec/sys_exec_linux.go | Go | bsd-3-clause | 363 |
//go:build windows
// +build windows
package sys_exec
import "os/exec"
func BuildCmd(cmdStr string) *exec.Cmd {
return exec.Command("cmd", "/C", cmdStr)
}
| 2302_79757062/crawlab | core/sys_exec/sys_exec_windows.go | Go | bsd-3-clause | 159 |
package system
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
mongo2 "github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
... | 2302_79757062/crawlab | core/system/service.go | Go | bsd-3-clause | 1,512 |
package task
import (
"fmt"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/delegate"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/cr... | 2302_79757062/crawlab | core/task/base.go | Go | bsd-3-clause | 2,202 |
package handler
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"time"
)
type Option func(svc interfaces.TaskHandlerService)
func WithConfigPath(path string) Option {
return func(svc interfaces.TaskHandlerService) {
svc.SetConfigPath(path)
}
}
func WithExitWatchDuration(duration time.Duration) Opti... | 2302_79757062/crawlab | core/task/handler/options.go | Go | bsd-3-clause | 899 |
package handler
import (
"bufio"
"context"
"encoding/json"
"fmt"
"github.com/apex/log"
"github.com/cenkalti/backoff/v4"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/errors"... | 2302_79757062/crawlab | core/task/handler/runner.go | Go | bsd-3-clause | 16,765 |
package handler
import (
"bufio"
"context"
"encoding/json"
"fmt"
"github.com/apex/log"
"github.com/cenkalti/backoff/v4"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/core/errors"... | 2302_79757062/crawlab | core/task/handler/runner_v2.go | Go | bsd-3-clause | 16,103 |
package handler
import (
"context"
"encoding/json"
"errors"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
errors2 "github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/c... | 2302_79757062/crawlab | core/task/handler/service.go | Go | bsd-3-clause | 12,542 |
package handler
import (
"context"
"encoding/json"
"errors"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/constants"
errors2 "github.com/crawlab-team/crawlab/core/errors"
grpcclient "github.com/crawlab-team/crawlab/core/grpc/client"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/c... | 2302_79757062/crawlab | core/task/handler/service_v2.go | Go | bsd-3-clause | 9,856 |
package log
const (
MetadataName = "metadata.json"
)
const (
DriverTypeFile = "file" // raw file
DriverTypeFs = "fs" // file system (SeaweedFS)
DriverTypeMongo = "mongo" // mongodb
DriverTypeEs = "es" // elastic search
)
| 2302_79757062/crawlab | core/task/log/constants.go | Go | bsd-3-clause | 242 |
package log
import "time"
var DefaultLogTtl = 30 * 24 * time.Hour
| 2302_79757062/crawlab | core/task/log/default.go | Go | bsd-3-clause | 68 |
package log
func GetLogDriver(logDriverType string) (driver Driver, err error) {
switch logDriverType {
case DriverTypeFile:
driver, err = GetFileLogDriver()
if err != nil {
return driver, err
}
case DriverTypeMongo:
return driver, ErrNotImplemented
case DriverTypeEs:
return driver, ErrNotImplemented
... | 2302_79757062/crawlab | core/task/log/driver.go | Go | bsd-3-clause | 387 |
package log
import "time"
type Message struct {
Id int64 `json:"id" bson:"id"`
Msg string `json:"msg" bson:"msg"`
Ts time.Time `json:"ts" bson:"ts"`
}
type Metadata struct {
Size int64 `json:"size,omitempty" bson:"size"`
TotalLines int64 `json:"total_lines,omitempty" bson:"total_lines"`
TotalB... | 2302_79757062/crawlab | core/task/log/entity.go | Go | bsd-3-clause | 437 |
package log
import "errors"
var (
ErrInvalidType = errors.New("invalid type")
ErrNotImplemented = errors.New("not implemented")
)
| 2302_79757062/crawlab | core/task/log/errors.go | Go | bsd-3-clause | 137 |
package log
import (
"bufio"
"bytes"
"errors"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/utils"
"github.com/crawlab-team/crawlab/trace"
"github.com/spf13/viper"
"io"
"os"
"path/filepath"
"strconv"
"strings"
"sync"
"time"
)
type FileLogDriver struct {
// settings
logFileName string
ro... | 2302_79757062/crawlab | core/task/log/file_driver.go | Go | bsd-3-clause | 5,775 |
package log
type Driver interface {
Init() (err error)
Close() (err error)
WriteLine(id string, line string) (err error)
WriteLines(id string, lines []string) (err error)
Find(id string, pattern string, skip int, limit int) (lines []string, err error)
Count(id string, pattern string) (n int, err error)
}
| 2302_79757062/crawlab | core/task/log/interface.go | Go | bsd-3-clause | 313 |
package scheduler
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"time"
)
type Option func(svc interfaces.TaskSchedulerService)
func WithConfigPath(path string) Option {
return func(svc interfaces.TaskSchedulerService) {
svc.SetConfigPath(path)
}
}
func WithInterval(interval time.Duration) Option ... | 2302_79757062/crawlab | core/task/scheduler/options.go | Go | bsd-3-clause | 407 |
package scheduler
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/delegate"
"github.com/crawlab-team/crawlab/core... | 2302_79757062/crawlab | core/task/scheduler/service.go | Go | bsd-3-clause | 6,331 |
package scheduler
import (
errors2 "errors"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-t... | 2302_79757062/crawlab | core/task/scheduler/service_v2.go | Go | bsd-3-clause | 6,438 |
package stats
import "github.com/crawlab-team/crawlab/core/interfaces"
type Option func(service interfaces.TaskStatsService)
func WithConfigPath(path string) Option {
return func(svc interfaces.TaskStatsService) {
svc.SetConfigPath(path)
}
}
| 2302_79757062/crawlab | core/task/stats/options.go | Go | bsd-3-clause | 249 |
package stats
import (
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/result"
"github.com/crawlab-team/crawlab/core/task"
"github.com/crawlab-team/crawlab/core/task/log"... | 2302_79757062/crawlab | core/task/stats/service.go | Go | bsd-3-clause | 3,523 |
package stats
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
nodeconfig "github.com/crawlab-team/crawlab/core/node/config"
"github.com/crawlab-team/crawlab/core/result"
"github.com/crawlab-team/... | 2302_79757062/crawlab | core/task/stats/service_v2.go | Go | bsd-3-clause | 3,148 |
package user
import "github.com/crawlab-team/crawlab/core/interfaces"
type Option func(svc interfaces.UserService)
func WithJwtSecret(secret string) Option {
return func(svc interfaces.UserService) {
svc.SetJwtSecret(secret)
}
}
| 2302_79757062/crawlab | core/user/options.go | Go | bsd-3-clause | 236 |
package user
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/container"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/delegate"
"github.com/crawlab-team/crawlab/core/mode... | 2302_79757062/crawlab | core/user/service.go | Go | bsd-3-clause | 5,767 |
package user
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/u... | 2302_79757062/crawlab | core/user/service_v2.go | Go | bsd-3-clause | 5,090 |
package test
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/service"
"github.com/crawlab-team/crawlab/core/user"
"go.uber.org/dig"
"testing"
)
func init() {
var err error
T, err = NewTest()
if err != nil {
panic(err)
}
}
var T *Test
type Test struc... | 2302_79757062/crawlab | core/user/test/base.go | Go | bsd-3-clause | 1,179 |
package utils
import "github.com/crawlab-team/crawlab/core/interfaces"
func GetUserFromArgs(args ...interface{}) (u interfaces.User) {
for _, arg := range args {
switch arg.(type) {
case interfaces.User:
var ok bool
u, ok = arg.(interfaces.User)
if ok {
return u
}
}
}
return nil
}
| 2302_79757062/crawlab | core/utils/args.go | Go | bsd-3-clause | 309 |
package utils
import (
"errors"
"math/rand"
"reflect"
"time"
)
func StringArrayContains(arr []string, str string) bool {
for _, s := range arr {
if s == str {
return true
}
}
return false
}
func GetArrayItems(array interface{}) (res []interface{}, err error) {
switch reflect.TypeOf(array).Kind() {
ca... | 2302_79757062/crawlab | core/utils/array.go | Go | bsd-3-clause | 901 |
package utils
import (
"github.com/apex/log"
"github.com/cenkalti/backoff/v4"
"github.com/crawlab-team/crawlab/trace"
"time"
)
func BackoffErrorNotify(prefix string) backoff.Notify {
return func(err error, duration time.Duration) {
log.Errorf("%s error: %v. reattempt in %.1f seconds...", prefix, err, duration.... | 2302_79757062/crawlab | core/utils/backoff.go | Go | bsd-3-clause | 360 |
package binders
import (
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
)
func NewColNameBinder(id interfaces.ModelId) (b *ColNameBinder) {
return &ColNameBinder{id: id}
}
type ColNameBinder struct {
id interfaces.ModelId
}
func (b *ColNameBinder) Bind() (res int... | 2302_79757062/crawlab | core/utils/binders/binder_col_name.go | Go | bsd-3-clause | 2,922 |
package utils
import "github.com/spf13/viper"
func EnvIsTrue(key string, defaultOk bool) bool {
isTrueBool := viper.GetBool(key)
isTrueString := viper.GetString(key)
if isTrueString == "" {
return defaultOk
}
return isTrueBool || isTrueString == "Y"
}
| 2302_79757062/crawlab | core/utils/bool.go | Go | bsd-3-clause | 261 |
package utils
import (
"github.com/emirpasic/gods/sets/hashset"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"reflect"
)
func BsonMEqual(v1, v2 bson.M) (ok bool) {
//ok = reflect.DeepEqual(v1, v2)
ok = bsonMEqual(v1, v2)
return ok
}
func bsonMEqual(v1, v2 bson.M) (ok bool) {... | 2302_79757062/crawlab | core/utils/bson.go | Go | bsd-3-clause | 2,171 |
package utils
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
mongo2 "go.mongodb.org/mongo-driver/mongo"
"time"
)
func GetFromDbCache(key string, getFn func() (string, error)) (res string, err error) {
col := mongo.GetMongoC... | 2302_79757062/crawlab | core/utils/cache.go | Go | bsd-3-clause | 1,207 |
package utils
import (
"sync"
)
var TaskExecChanMap = NewChanMap()
type ChanMap struct {
m sync.Map
}
func NewChanMap() *ChanMap {
return &ChanMap{m: sync.Map{}}
}
func (cm *ChanMap) Chan(key string) chan string {
if ch, ok := cm.m.Load(key); ok {
return ch.(interface{}).(chan string)
}
ch := make(chan str... | 2302_79757062/crawlab | core/utils/chan.go | Go | bsd-3-clause | 675 |
package utils
import (
"context"
"fmt"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/upper/db/v4"
"github.com/upper/db/v4/adapter/mssql"
"time"
)
func GetCockroachdbSession(ds *models.DataSource) (s db.Session, err error) {
return getCockroac... | 2302_79757062/crawlab | core/utils/cockroachdb.go | Go | bsd-3-clause | 1,306 |
package utils
import (
"fmt"
"math"
"strconv"
"strings"
)
// cronBounds provides a range of acceptable values (plus a map of name to value).
type cronBounds struct {
min, max uint
names map[string]uint
}
type cronUtils struct {
// The cronBounds for each field.
seconds cronBounds
minutes cronBounds
hour... | 2302_79757062/crawlab | core/utils/cron.go | Go | bsd-3-clause | 4,014 |
package utils
import (
"fmt"
"github.com/spf13/viper"
"time"
)
func IsDebug() bool {
return viper.GetBool("debug")
}
func LogDebug(msg string) {
if !IsDebug() {
return
}
fmt.Println(fmt.Sprintf("[DEBUG] %s: %s", time.Now().Format("2006-01-02 15:04:05"), msg))
}
| 2302_79757062/crawlab | core/utils/debug.go | Go | bsd-3-clause | 274 |
package utils
import (
"fmt"
"github.com/crawlab-team/crawlab/core/sys_exec"
"github.com/crawlab-team/crawlab/db/mongo"
"github.com/crawlab-team/crawlab/trace"
"github.com/spf13/viper"
)
func GetApiAddress() (res string) {
apiAddress := viper.GetString("api.address")
if apiAddress == "" {
return "http://loca... | 2302_79757062/crawlab | core/utils/demo.go | Go | bsd-3-clause | 1,270 |
package utils
import (
"github.com/crawlab-team/crawlab/trace"
"github.com/spf13/viper"
"go.uber.org/dig"
"os"
)
func VisualizeContainer(c *dig.Container) (err error) {
if !viper.GetBool("debug.di.visualize") {
return nil
}
if err := dig.Visualize(c, os.Stdout); err != nil {
return trace.TraceError(err)
}... | 2302_79757062/crawlab | core/utils/di.go | Go | bsd-3-clause | 335 |
package utils
func IsDocker() (ok bool) {
return EnvIsTrue("docker", false)
}
| 2302_79757062/crawlab | core/utils/docker.go | Go | bsd-3-clause | 80 |
package utils
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/hmac"
"crypto/md5"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"fmt"
"github.com/crawlab-team/crawlab/core/constants"
"io"
)
func GetSecretKey() string {
return constants.DefaultEncryptServerKey
}
func GetSecretKeyBytes() []byte {
... | 2302_79757062/crawlab | core/utils/encrypt.go | Go | bsd-3-clause | 1,770 |
package utils
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/cenkalti/backoff/v4"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/db/generic"
"github.com/crawlab-team/crawlab/trace"
"github.com/elastic/go-ela... | 2302_79757062/crawlab | core/utils/es.go | Go | bsd-3-clause | 3,854 |
package utils
import (
"archive/zip"
"crypto/md5"
"encoding/hex"
"fmt"
"github.com/apex/log"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/entity"
"io"
"io/fs"
"os"
"path"
"path/filepath"
"runtime/debug"
)
func OpenFile(fileName string) *os.File {
file, err := os... | 2302_79757062/crawlab | core/utils/file.go | Go | bsd-3-clause | 7,712 |
package utils
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/errors"
"github.com/crawlab-team/crawlab/core/interfaces"
"go.mongodb.org/mongo-driver/bson"
)
// FilterToQuery Translate entity.Filter to bson.M
func FilterToQuery(f interfaces.Filter) (q bson.M, err err... | 2302_79757062/crawlab | core/utils/filter.go | Go | bsd-3-clause | 1,427 |
package utils
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/interfaces"
"github.com/crawlab-team/crawlab/core/models/models"
vcs "github.com/crawlab-team/crawlab/vcs"
)
func InitGitClientAuth(g interfaces.Git, gitClient *vcs.GitClient) {
// set auth
switch g.Get... | 2302_79757062/crawlab | core/utils/git.go | Go | bsd-3-clause | 1,068 |
package utils
import (
"github.com/crawlab-team/crawlab/trace"
"io"
"reflect"
"unsafe"
)
func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
func Close(c io.Closer) {
err := c.Close()
if err != nil {
trace.PrintError(err)
}
}
func Contains(array interface{}, val interface{}) (fla... | 2302_79757062/crawlab | core/utils/helpers.go | Go | bsd-3-clause | 583 |
package utils
import (
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/entity"
"github.com/crawlab-team/crawlab/trace"
"github.com/gin-gonic/gin"
"net/http"
)
func handleError(statusCode int, c *gin.Context, err error, print bool) {
if print {
trace.PrintError(err)
}
c... | 2302_79757062/crawlab | core/utils/http.go | Go | bsd-3-clause | 822 |
package utils
import (
"github.com/crawlab-team/crawlab/core/interfaces"
"sync"
)
var moduleInitializedMap = sync.Map{}
func InitModule(id interfaces.ModuleId, fn func() error) (err error) {
res, ok := moduleInitializedMap.Load(id)
if ok {
initialized, _ := res.(bool)
if initialized {
return nil
}
}
... | 2302_79757062/crawlab | core/utils/init.go | Go | bsd-3-clause | 487 |
package utils
import "encoding/json"
func JsonToBytes(d interface{}) (bytes []byte, err error) {
switch d.(type) {
case []byte:
return d.([]byte), nil
default:
return json.Marshal(d)
}
}
| 2302_79757062/crawlab | core/utils/json.go | Go | bsd-3-clause | 197 |
package utils
import (
"context"
"fmt"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/segmentio/kafka-go"
"time"
)
func GetKafkaConnection(ds *models.DataSource) (c *kafka.Conn, err error) {
return getKafkaConnection(context.Background(), ds)
}... | 2302_79757062/crawlab | core/utils/kafka.go | Go | bsd-3-clause | 1,064 |
package utils
import (
"context"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/crawlab-team/crawlab/db/generic"
"github.com/crawlab-team/crawlab/db/mongo"
"go.mongodb.org/mongo-driver/bson"
mongo2 "go.mongodb.org/mongo-driver/mongo"
"time"
)
... | 2302_79757062/crawlab | core/utils/mongo.go | Go | bsd-3-clause | 2,387 |
package utils
import (
"context"
"fmt"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/upper/db/v4"
"github.com/upper/db/v4/adapter/mssql"
"time"
)
func GetMssqlSession(ds *models.DataSource) (s db.Session, err error) {
return getMssqlSession(c... | 2302_79757062/crawlab | core/utils/mssql.go | Go | bsd-3-clause | 1,270 |
package utils
import (
"context"
"fmt"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/upper/db/v4"
"github.com/upper/db/v4/adapter/mysql"
"time"
)
func GetMysqlSession(ds *models.DataSource) (s db.Session, err error) {
return getMysqlSession(c... | 2302_79757062/crawlab | core/utils/mysql.go | Go | bsd-3-clause | 1,270 |
package utils
func IsMaster() bool {
return EnvIsTrue("node.master", false)
}
func GetNodeType() string {
if IsMaster() {
return "master"
} else {
return "worker"
}
}
| 2302_79757062/crawlab | core/utils/node.go | Go | bsd-3-clause | 177 |
package utils
import (
"os"
"os/signal"
"syscall"
)
func DefaultWait() {
quit := make(chan os.Signal, 1)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
}
| 2302_79757062/crawlab | core/utils/os.go | Go | bsd-3-clause | 175 |
package utils
import (
"context"
"fmt"
"github.com/crawlab-team/crawlab/core/constants"
"github.com/crawlab-team/crawlab/core/models/models"
"github.com/upper/db/v4"
"github.com/upper/db/v4/adapter/postgresql"
"time"
)
func GetPostgresqlSession(ds *models.DataSource) (s db.Session, err error) {
return getPost... | 2302_79757062/crawlab | core/utils/postgresql.go | Go | bsd-3-clause | 1,315 |