xsqlite

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbService_GetHandler_FullMethodName         = "/x.db.DbService/GetHandler"
	DbService_GetAllHandlers_FullMethodName     = "/x.db.DbService/GetAllHandlers"
	DbService_GetHandlersByGroup_FullMethodName = "/x.db.DbService/GetHandlersByGroup"
	DbService_GetBatchedHandlers_FullMethodName = "/x.db.DbService/GetBatchedHandlers"
	DbService_UpdateHandler_FullMethodName      = "/x.db.DbService/UpdateHandler"
)

Variables

View Source
var DbService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "x.db.DbService",
	HandlerType: (*DbServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetHandler",
			Handler:    _DbService_GetHandler_Handler,
		},
		{
			MethodName: "GetAllHandlers",
			Handler:    _DbService_GetAllHandlers_Handler,
		},
		{
			MethodName: "GetHandlersByGroup",
			Handler:    _DbService_GetHandlersByGroup_Handler,
		},
		{
			MethodName: "GetBatchedHandlers",
			Handler:    _DbService_GetBatchedHandlers_Handler,
		},
		{
			MethodName: "UpdateHandler",
			Handler:    _DbService_UpdateHandler_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "protos/db/db.proto",
}

DbService_ServiceDesc is the grpc.ServiceDesc for DbService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_protos_db_db_proto protoreflect.FileDescriptor

Functions

func RegisterDbServiceServer

func RegisterDbServiceServer(s grpc.ServiceRegistrar, srv DbServiceServer)

Types

type Database

type Database struct {
	*gorm.DB
}

func (*Database) Close

func (d *Database) Close() error

func (*Database) GetAllHandlers

func (d *Database) GetAllHandlers() ([]*OutboundHandler, error)

func (*Database) GetBatchedHandlers

func (d *Database) GetBatchedHandlers(batchSize int, offset int) ([]*OutboundHandler, error)

func (*Database) GetHandler

func (d *Database) GetHandler(id int) *OutboundHandler

func (*Database) GetHandlerByTag

func (d *Database) GetHandlerByTag(tag string) *OutboundHandler

tag is string of id

func (*Database) GetHandlersByGroup

func (d *Database) GetHandlersByGroup(group string) ([]*OutboundHandler, error)

func (*Database) GetHighestSpeedHandler

func (d *Database) GetHighestSpeedHandler() *OutboundHandler

func (*Database) UpdateHandler

func (d *Database) UpdateHandler(id int, m map[string]interface{}) error

type Db

type Db struct {
	// contains filtered or unexported fields
}

func NewDb

func NewDb(secret string, serverPort uint16) (*Db, error)

func (*Db) Close

func (d *Db) Close() error

func (*Db) GetAllHandlers

func (d *Db) GetAllHandlers() ([]*OutboundHandler, error)

func (*Db) GetBatchedHandlers

func (d *Db) GetBatchedHandlers(batchSize int, offset int) ([]*OutboundHandler, error)

func (*Db) GetHandler

func (d *Db) GetHandler(id int) *OutboundHandler

func (*Db) GetHandlersByGroup

func (d *Db) GetHandlersByGroup(group string) ([]*OutboundHandler, error)

func (*Db) GetRequestMetadata

func (a *Db) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

func (*Db) RequireTransportSecurity

func (a *Db) RequireTransportSecurity() bool

func (*Db) UpdateHandler

func (d *Db) UpdateHandler(id int, m map[string]interface{}) error

type DbHandlers

type DbHandlers struct {
	Handlers []*DbOutboundHandler `protobuf:"bytes,1,rep,name=handlers,proto3" json:"handlers,omitempty"`
	// contains filtered or unexported fields
}

func (*DbHandlers) Descriptor deprecated

func (*DbHandlers) Descriptor() ([]byte, []int)

Deprecated: Use DbHandlers.ProtoReflect.Descriptor instead.

func (*DbHandlers) GetHandlers

func (x *DbHandlers) GetHandlers() []*DbOutboundHandler

func (*DbHandlers) ProtoMessage

func (*DbHandlers) ProtoMessage()

func (*DbHandlers) ProtoReflect

func (x *DbHandlers) ProtoReflect() protoreflect.Message

func (*DbHandlers) Reset

func (x *DbHandlers) Reset()

func (*DbHandlers) String

func (x *DbHandlers) String() string

type DbOutboundHandler

type DbOutboundHandler struct {
	Id               int64   `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Tag              string  `protobuf:"bytes,2,opt,name=tag,proto3" json:"tag,omitempty"`
	Ok               int32   `protobuf:"varint,3,opt,name=ok,proto3" json:"ok,omitempty"`
	Speed            float32 `protobuf:"fixed32,4,opt,name=speed,proto3" json:"speed,omitempty"`
	SpeedTestTime    int32   `protobuf:"varint,5,opt,name=speed_test_time,json=speedTestTime,proto3" json:"speed_test_time,omitempty"`
	Ping             int32   `protobuf:"varint,6,opt,name=ping,proto3" json:"ping,omitempty"`
	PingTestTime     int32   `protobuf:"varint,7,opt,name=ping_test_time,json=pingTestTime,proto3" json:"ping_test_time,omitempty"`
	Support6         int32   `protobuf:"varint,8,opt,name=support6,proto3" json:"support6,omitempty"`
	Support6TestTime int32   `protobuf:"varint,9,opt,name=support6_test_time,json=support6TestTime,proto3" json:"support6_test_time,omitempty"`
	Config           []byte  `protobuf:"bytes,10,opt,name=config,proto3" json:"config,omitempty"`
	Selected         bool    `protobuf:"varint,11,opt,name=selected,proto3" json:"selected,omitempty"`
	SubId            int64   `protobuf:"varint,12,opt,name=sub_id,json=subId,proto3" json:"sub_id,omitempty"`
	// contains filtered or unexported fields
}

func (*DbOutboundHandler) Descriptor deprecated

func (*DbOutboundHandler) Descriptor() ([]byte, []int)

Deprecated: Use DbOutboundHandler.ProtoReflect.Descriptor instead.

func (*DbOutboundHandler) GetConfig

func (x *DbOutboundHandler) GetConfig() []byte

func (*DbOutboundHandler) GetId

func (x *DbOutboundHandler) GetId() int64

func (*DbOutboundHandler) GetOk

func (x *DbOutboundHandler) GetOk() int32

func (*DbOutboundHandler) GetPing

func (x *DbOutboundHandler) GetPing() int32

func (*DbOutboundHandler) GetPingTestTime

func (x *DbOutboundHandler) GetPingTestTime() int32

func (*DbOutboundHandler) GetSelected

func (x *DbOutboundHandler) GetSelected() bool

func (*DbOutboundHandler) GetSpeed

func (x *DbOutboundHandler) GetSpeed() float32

func (*DbOutboundHandler) GetSpeedTestTime

func (x *DbOutboundHandler) GetSpeedTestTime() int32

func (*DbOutboundHandler) GetSubId

func (x *DbOutboundHandler) GetSubId() int64

func (*DbOutboundHandler) GetSupport6

func (x *DbOutboundHandler) GetSupport6() int32

func (*DbOutboundHandler) GetSupport6TestTime

func (x *DbOutboundHandler) GetSupport6TestTime() int32

func (*DbOutboundHandler) GetTag

func (x *DbOutboundHandler) GetTag() string

func (*DbOutboundHandler) ProtoMessage

func (*DbOutboundHandler) ProtoMessage()

func (*DbOutboundHandler) ProtoReflect

func (x *DbOutboundHandler) ProtoReflect() protoreflect.Message

func (*DbOutboundHandler) Reset

func (x *DbOutboundHandler) Reset()

func (*DbOutboundHandler) String

func (x *DbOutboundHandler) String() string

func (*DbOutboundHandler) ToOutboundHandler

func (d *DbOutboundHandler) ToOutboundHandler() *OutboundHandler

type DbServiceClient

type DbServiceClient interface {
	GetHandler(ctx context.Context, in *GetHandlerRequest, opts ...grpc.CallOption) (*DbOutboundHandler, error)
	GetAllHandlers(ctx context.Context, in *GetAllHandlersRequest, opts ...grpc.CallOption) (*DbHandlers, error)
	GetHandlersByGroup(ctx context.Context, in *GetHandlersByGroupRequest, opts ...grpc.CallOption) (*DbHandlers, error)
	GetBatchedHandlers(ctx context.Context, in *GetBatchedHandlersRequest, opts ...grpc.CallOption) (*DbHandlers, error)
	UpdateHandler(ctx context.Context, in *UpdateHandlerRequest, opts ...grpc.CallOption) (*Receipt, error)
}

DbServiceClient is the client API for DbService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewDbServiceClient

func NewDbServiceClient(cc grpc.ClientConnInterface) DbServiceClient

type DbServiceServer

type DbServiceServer interface {
	GetHandler(context.Context, *GetHandlerRequest) (*DbOutboundHandler, error)
	GetAllHandlers(context.Context, *GetAllHandlersRequest) (*DbHandlers, error)
	GetHandlersByGroup(context.Context, *GetHandlersByGroupRequest) (*DbHandlers, error)
	GetBatchedHandlers(context.Context, *GetBatchedHandlersRequest) (*DbHandlers, error)
	UpdateHandler(context.Context, *UpdateHandlerRequest) (*Receipt, error)
	// contains filtered or unexported methods
}

DbServiceServer is the server API for DbService service. All implementations must embed UnimplementedDbServiceServer for forward compatibility.

type GetAllHandlersRequest

type GetAllHandlersRequest struct {
	// contains filtered or unexported fields
}

func (*GetAllHandlersRequest) Descriptor deprecated

func (*GetAllHandlersRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetAllHandlersRequest.ProtoReflect.Descriptor instead.

func (*GetAllHandlersRequest) ProtoMessage

func (*GetAllHandlersRequest) ProtoMessage()

func (*GetAllHandlersRequest) ProtoReflect

func (x *GetAllHandlersRequest) ProtoReflect() protoreflect.Message

func (*GetAllHandlersRequest) Reset

func (x *GetAllHandlersRequest) Reset()

func (*GetAllHandlersRequest) String

func (x *GetAllHandlersRequest) String() string

type GetBatchedHandlersRequest

type GetBatchedHandlersRequest struct {
	BatchSize uint32 `protobuf:"varint,1,opt,name=batch_size,json=batchSize,proto3" json:"batch_size,omitempty"`
	Offset    uint32 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
	// contains filtered or unexported fields
}

func (*GetBatchedHandlersRequest) Descriptor deprecated

func (*GetBatchedHandlersRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetBatchedHandlersRequest.ProtoReflect.Descriptor instead.

func (*GetBatchedHandlersRequest) GetBatchSize

func (x *GetBatchedHandlersRequest) GetBatchSize() uint32

func (*GetBatchedHandlersRequest) GetOffset

func (x *GetBatchedHandlersRequest) GetOffset() uint32

func (*GetBatchedHandlersRequest) ProtoMessage

func (*GetBatchedHandlersRequest) ProtoMessage()

func (*GetBatchedHandlersRequest) ProtoReflect

func (*GetBatchedHandlersRequest) Reset

func (x *GetBatchedHandlersRequest) Reset()

func (*GetBatchedHandlersRequest) String

func (x *GetBatchedHandlersRequest) String() string

type GetHandlerRequest

type GetHandlerRequest struct {
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

func (*GetHandlerRequest) Descriptor deprecated

func (*GetHandlerRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetHandlerRequest.ProtoReflect.Descriptor instead.

func (*GetHandlerRequest) GetId

func (x *GetHandlerRequest) GetId() int64

func (*GetHandlerRequest) ProtoMessage

func (*GetHandlerRequest) ProtoMessage()

func (*GetHandlerRequest) ProtoReflect

func (x *GetHandlerRequest) ProtoReflect() protoreflect.Message

func (*GetHandlerRequest) Reset

func (x *GetHandlerRequest) Reset()

func (*GetHandlerRequest) String

func (x *GetHandlerRequest) String() string

type GetHandlersByGroupRequest

type GetHandlersByGroupRequest struct {
	Group string `protobuf:"bytes,1,opt,name=group,proto3" json:"group,omitempty"`
	// contains filtered or unexported fields
}

func (*GetHandlersByGroupRequest) Descriptor deprecated

func (*GetHandlersByGroupRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetHandlersByGroupRequest.ProtoReflect.Descriptor instead.

func (*GetHandlersByGroupRequest) GetGroup

func (x *GetHandlersByGroupRequest) GetGroup() string

func (*GetHandlersByGroupRequest) ProtoMessage

func (*GetHandlersByGroupRequest) ProtoMessage()

func (*GetHandlersByGroupRequest) ProtoReflect

func (*GetHandlersByGroupRequest) Reset

func (x *GetHandlersByGroupRequest) Reset()

func (*GetHandlersByGroupRequest) String

func (x *GetHandlersByGroupRequest) String() string

type OutboundHandler

type OutboundHandler struct {
	ID          int
	Selected    bool
	CountryCode string
	Ok          int
	Speed       float64
	// in seconds
	SpeedTestTime    int
	Ping             int
	PingTestTime     int
	SubId            *int
	Config           []byte
	Sni              string
	ServerIp         string
	Support6         int
	Support6TestTime int
}

func (*OutboundHandler) GetPing

func (h *OutboundHandler) GetPing() int

func (*OutboundHandler) GetSpeed

func (h *OutboundHandler) GetSpeed() float64

func (*OutboundHandler) GetSupport6

func (h *OutboundHandler) GetSupport6() int

func (*OutboundHandler) GetTag

func (h *OutboundHandler) GetTag() string

func (*OutboundHandler) IsPingDataOld

func (h *OutboundHandler) IsPingDataOld() bool

if last test time is more than 10 minutes ago, return true

func (*OutboundHandler) IsSpeedDataOld

func (h *OutboundHandler) IsSpeedDataOld() bool

if last test time is more than 10 minutes ago, return true

func (*OutboundHandler) IsSupport6DataOld

func (h *OutboundHandler) IsSupport6DataOld() bool

func (*OutboundHandler) ToConfig

func (h *OutboundHandler) ToConfig() *configs.HandlerConfig

type OutboundHandlerGroup

type OutboundHandlerGroup struct {
	Name string `gorm:"primaryKey;not null"`
}

type OutboundHandlerGroupRelation

type OutboundHandlerGroupRelation struct {
	GroupName string `gorm:"not null;foreignKey:Name;references:OutboundHandlerGroup"`
	HandlerId int    `gorm:"not null;foreignKey:ID;references:OutboundHandler"`
}

type Pref

type Pref struct {
	ID                     int
	SubscriptionLastUpdate int
}

type Receipt

type Receipt struct {
	// contains filtered or unexported fields
}

func (*Receipt) Descriptor deprecated

func (*Receipt) Descriptor() ([]byte, []int)

Deprecated: Use Receipt.ProtoReflect.Descriptor instead.

func (*Receipt) ProtoMessage

func (*Receipt) ProtoMessage()

func (*Receipt) ProtoReflect

func (x *Receipt) ProtoReflect() protoreflect.Message

func (*Receipt) Reset

func (x *Receipt) Reset()

func (*Receipt) String

func (x *Receipt) String() string

type Subscription

type Subscription struct {
	ID                int
	Name              string
	Link              string
	RemainingData     float64
	EndTime           int
	Website           string
	LastUpdate        int
	LastSuccessUpdate int
	Description       string
}

type UnimplementedDbServiceServer

type UnimplementedDbServiceServer struct{}

UnimplementedDbServiceServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedDbServiceServer) GetAllHandlers

func (UnimplementedDbServiceServer) GetBatchedHandlers

func (UnimplementedDbServiceServer) GetHandler

func (UnimplementedDbServiceServer) GetHandlersByGroup

func (UnimplementedDbServiceServer) UpdateHandler

type UnsafeDbServiceServer

type UnsafeDbServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeDbServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to DbServiceServer will result in compilation errors.

type UpdateHandlerRequest

type UpdateHandlerRequest struct {
	Id               int64    `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Ok               *int32   `protobuf:"varint,2,opt,name=ok,proto3,oneof" json:"ok,omitempty"`
	Speed            *float32 `protobuf:"fixed32,3,opt,name=speed,proto3,oneof" json:"speed,omitempty"`
	Ping             *int32   `protobuf:"varint,4,opt,name=ping,proto3,oneof" json:"ping,omitempty"`
	Support6         *int32   `protobuf:"varint,5,opt,name=support6,proto3,oneof" json:"support6,omitempty"`
	SpeedTestTime    *int32   `protobuf:"varint,6,opt,name=speed_test_time,json=speedTestTime,proto3,oneof" json:"speed_test_time,omitempty"`
	PingTestTime     *int32   `protobuf:"varint,7,opt,name=ping_test_time,json=pingTestTime,proto3,oneof" json:"ping_test_time,omitempty"`
	Support6TestTime *int32   `protobuf:"varint,8,opt,name=support6_test_time,json=support6TestTime,proto3,oneof" json:"support6_test_time,omitempty"`
	// contains filtered or unexported fields
}

func (*UpdateHandlerRequest) Descriptor deprecated

func (*UpdateHandlerRequest) Descriptor() ([]byte, []int)

Deprecated: Use UpdateHandlerRequest.ProtoReflect.Descriptor instead.

func (*UpdateHandlerRequest) GetId

func (x *UpdateHandlerRequest) GetId() int64

func (*UpdateHandlerRequest) GetOk

func (x *UpdateHandlerRequest) GetOk() int32

func (*UpdateHandlerRequest) GetPing

func (x *UpdateHandlerRequest) GetPing() int32

func (*UpdateHandlerRequest) GetPingTestTime

func (x *UpdateHandlerRequest) GetPingTestTime() int32

func (*UpdateHandlerRequest) GetSpeed

func (x *UpdateHandlerRequest) GetSpeed() float32

func (*UpdateHandlerRequest) GetSpeedTestTime

func (x *UpdateHandlerRequest) GetSpeedTestTime() int32

func (*UpdateHandlerRequest) GetSupport6

func (x *UpdateHandlerRequest) GetSupport6() int32

func (*UpdateHandlerRequest) GetSupport6TestTime

func (x *UpdateHandlerRequest) GetSupport6TestTime() int32

func (*UpdateHandlerRequest) ProtoMessage

func (*UpdateHandlerRequest) ProtoMessage()

func (*UpdateHandlerRequest) ProtoReflect

func (x *UpdateHandlerRequest) ProtoReflect() protoreflect.Message

func (*UpdateHandlerRequest) Reset

func (x *UpdateHandlerRequest) Reset()

func (*UpdateHandlerRequest) String

func (x *UpdateHandlerRequest) String() string

Jump to

Keyboard shortcuts

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