Documentation ¶
Index ¶
- Variables
- func ConnectMongoDB(uri string) (*mongo.Client, error)
- func ToFindOptions(listOptions *entity.HostFindOptions) *options.FindOptions
- type FindOptions
- type HostMongodbRepository
- func (h *HostMongodbRepository) AddHostRule(ctx context.Context, hostID string, ruleIDs ...string) error
- func (h *HostMongodbRepository) Create(ctx context.Context, host *entity.Host) (*entity.Host, error)
- func (h *HostMongodbRepository) Delete(ctx context.Context, id string) error
- func (h *HostMongodbRepository) DeleteHostRule(ctx context.Context, hostID string, ruleID ...string) error
- func (h *HostMongodbRepository) EnrollHost(ctx context.Context, enrollHost *entity.EnrollHost) error
- func (h *HostMongodbRepository) Find(ctx context.Context, options *entity.HostFindOptions) ([]*entity.Host, error)
- func (h *HostMongodbRepository) Get(ctx context.Context, id string) (*entity.Host, error)
- func (h *HostMongodbRepository) GetEnrollHost(ctx context.Context, getEnrollHost *entity.GetEnrollHost) (*entity.EnrollHost, error)
- func (h *HostMongodbRepository) GetHostByEnrollCode(ctx context.Context, code string) (*entity.Host, error)
- func (h *HostMongodbRepository) HostOffline(ctx context.Context, hostOffline *entity.HostOffline) (*entity.HostOffline, error)
- func (h *HostMongodbRepository) HostOnline(ctx context.Context, hostOnline *entity.HostOnline) (*entity.HostOnline, error)
- func (h *HostMongodbRepository) ListHostRule(ctx context.Context, opts *entity.ListHostRuleOptions) ([]*entity.HostRuleRelation, error)
- func (h *HostMongodbRepository) Update(ctx context.Context, host *entity.Host) (*entity.Host, error)
- type MongoDBRepository
- func (m *MongoDBRepository) AllocateIP(ctx context.Context, id string, ip string) error
- func (m *MongoDBRepository) AutoAllocateIP(ctx context.Context, id string) (string, error)
- func (m *MongoDBRepository) AvailableIPs(ctx context.Context, id string) ([]string, error)
- func (m *MongoDBRepository) Create(ctx context.Context, network *entity.Network) (*entity.Network, error)
- func (m *MongoDBRepository) Delete(ctx context.Context, id string) error
- func (m *MongoDBRepository) Find(ctx context.Context, query *entity.QueryNetwork) ([]*entity.Network, error)
- func (m *MongoDBRepository) Get(ctx context.Context, id string) (*entity.Network, error)
- func (m *MongoDBRepository) ReleaseIP(ctx context.Context, id string, ip string) error
- func (m *MongoDBRepository) Update(ctx context.Context, e *entity.Network) (*entity.Network, error)
- func (m *MongoDBRepository) UsedIPs(ctx context.Context, id string) ([]string, error)
- type NetWorkModel
- type NetworkMemoryRepository
- func (m *NetworkMemoryRepository) AllocateIP(ctx context.Context, id string, ip string) error
- func (m *NetworkMemoryRepository) AutoAllocateIP(ctx context.Context, id string) (string, error)
- func (m *NetworkMemoryRepository) AvailableIPs(ctx context.Context, id string) ([]string, error)
- func (m *NetworkMemoryRepository) Create(ctx context.Context, network *entity.Network) (*entity.Network, error)
- func (m *NetworkMemoryRepository) Delete(ctx context.Context, id string) error
- func (m *NetworkMemoryRepository) Find(ctx context.Context, query *entity.QueryNetwork) ([]*entity.Network, error)
- func (m *NetworkMemoryRepository) Get(ctx context.Context, id string) (*entity.Network, error)
- func (m *NetworkMemoryRepository) ReleaseIP(ctx context.Context, id string, ip string) error
- func (m *NetworkMemoryRepository) Update(ctx context.Context, e *entity.Network) (*entity.Network, error)
- func (m *NetworkMemoryRepository) UsedIPs(ctx context.Context, id string) ([]string, error)
- type Repositories
- type RuleMongodbRepository
- func (m *RuleMongodbRepository) Create(ctx context.Context, userID string, rule *entity.Rule) (*entity.Rule, error)
- func (m *RuleMongodbRepository) Delete(ctx context.Context, id string) error
- func (m *RuleMongodbRepository) Find(ctx context.Context, userID string, options *entity.RuleFindOptions) ([]*entity.Rule, error)
- func (m *RuleMongodbRepository) Get(ctx context.Context, userID, id string) (*entity.Rule, error)
- func (m *RuleMongodbRepository) Gets(ctx context.Context, userID string, ids []string) ([]*entity.Rule, error)
- func (m *RuleMongodbRepository) Update(ctx context.Context, userID string, rule *entity.Rule) error
- type UserMongodbRepository
- func (m *UserMongodbRepository) Create(ctx context.Context, user *entity.User) (*entity.User, error)
- func (m *UserMongodbRepository) Delete(ctx context.Context, id string) error
- func (m *UserMongodbRepository) Find(ctx context.Context, options *entity.FindOptions) ([]*entity.User, error)
- func (m *UserMongodbRepository) Get(ctx context.Context, id string) (*entity.User, error)
- func (m *UserMongodbRepository) Update(ctx context.Context, user *entity.User) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorNetworkNotFound = errors.New("network not found") ErrorNetworkExists = errors.New("network already exists") ErrorAddressNotInCIDRRange = errors.New("address is not within network CIDR range") ErrorAddressAlreadyAllocated = errors.New("address already allocated") ErrorAddressNotFoundInUsedIPs = errors.New("address not found in used IPs") ErrorCIDRInUse = errors.New("cidr already in use") ErrNoAvailableIP = errors.New("no available IP addresses in the network") )
View Source
var ErrorHostNotFound = errors.New("host not found")
Functions ¶
func ToFindOptions ¶
func ToFindOptions(listOptions *entity.HostFindOptions) *options.FindOptions
Types ¶
type FindOptions ¶
type HostMongodbRepository ¶
type HostMongodbRepository struct {
// contains filtered or unexported fields
}
func NewHostMongodbRepository ¶
func NewHostMongodbRepository(client *mongo.Client, dbName string) *HostMongodbRepository
func (*HostMongodbRepository) AddHostRule ¶
func (*HostMongodbRepository) Delete ¶
func (h *HostMongodbRepository) Delete(ctx context.Context, id string) error
func (*HostMongodbRepository) DeleteHostRule ¶
func (*HostMongodbRepository) EnrollHost ¶
func (h *HostMongodbRepository) EnrollHost(ctx context.Context, enrollHost *entity.EnrollHost) error
func (*HostMongodbRepository) Find ¶
func (h *HostMongodbRepository) Find(ctx context.Context, options *entity.HostFindOptions) ([]*entity.Host, error)
func (*HostMongodbRepository) GetEnrollHost ¶
func (h *HostMongodbRepository) GetEnrollHost(ctx context.Context, getEnrollHost *entity.GetEnrollHost) (*entity.EnrollHost, error)
func (*HostMongodbRepository) GetHostByEnrollCode ¶
func (*HostMongodbRepository) HostOffline ¶
func (h *HostMongodbRepository) HostOffline(ctx context.Context, hostOffline *entity.HostOffline) (*entity.HostOffline, error)
func (*HostMongodbRepository) HostOnline ¶
func (h *HostMongodbRepository) HostOnline(ctx context.Context, hostOnline *entity.HostOnline) (*entity.HostOnline, error)
func (*HostMongodbRepository) ListHostRule ¶
func (h *HostMongodbRepository) ListHostRule(ctx context.Context, opts *entity.ListHostRuleOptions) ([]*entity.HostRuleRelation, error)
type MongoDBRepository ¶
type MongoDBRepository struct {
// contains filtered or unexported fields
}
func NewNetworkMongoDBRepository ¶
func NewNetworkMongoDBRepository(client *mongo.Client, dbName string) *MongoDBRepository
func (*MongoDBRepository) AllocateIP ¶
func (*MongoDBRepository) AutoAllocateIP ¶
func (*MongoDBRepository) AvailableIPs ¶
func (*MongoDBRepository) Delete ¶
func (m *MongoDBRepository) Delete(ctx context.Context, id string) error
func (*MongoDBRepository) Find ¶
func (m *MongoDBRepository) Find(ctx context.Context, query *entity.QueryNetwork) ([]*entity.Network, error)
type NetWorkModel ¶
type NetWorkModel struct { ID string `json:"id"` Name string `json:"name"` Cidr string `json:"cidr"` Status uint `gorm:"comment:网络状态(0=正常状态, 1=锁定状态, 2=删除状态)"` CreatedAt int64 `gorm:"autoCreateTime;comment:创建时间"` UpdatedAt int64 `gorm:"autoUpdateTime;comment:更新时间"` DeletedAt int64 `gorm:"default:0;comment:删除时间"` UsedIPs []string // 存储分配的地址 AvailableIPs []string // 存储可用的地址 }
type NetworkMemoryRepository ¶
type NetworkMemoryRepository struct {
// contains filtered or unexported fields
}
func NewNetworkMemoryRepository ¶
func NewNetworkMemoryRepository() *NetworkMemoryRepository
func (*NetworkMemoryRepository) AllocateIP ¶
func (*NetworkMemoryRepository) AutoAllocateIP ¶
func (*NetworkMemoryRepository) AvailableIPs ¶
func (*NetworkMemoryRepository) Delete ¶
func (m *NetworkMemoryRepository) Delete(ctx context.Context, id string) error
func (*NetworkMemoryRepository) Find ¶
func (m *NetworkMemoryRepository) Find(ctx context.Context, query *entity.QueryNetwork) ([]*entity.Network, error)
type Repositories ¶
type Repositories struct { HostRepo repository.HostRepository RuleRepo repository.RuleRepository HostRuleRepo repository.HostRuleRepository NetworkRepo networkRepo.NetworkRepository // contains filtered or unexported fields }
func NewRepositories ¶
func NewRepositories(client *mongo.Client, dbName string) *Repositories
func (*Repositories) Automigrate ¶
func (r *Repositories) Automigrate() error
func (*Repositories) TXRepositories ¶
func (r *Repositories) TXRepositories(ctx context.Context, fc func(txr *Repositories, sessionCtx mongo.SessionContext) error) error
type RuleMongodbRepository ¶
type RuleMongodbRepository struct {
// contains filtered or unexported fields
}
func NewRuleMongodbRepository ¶
func NewRuleMongodbRepository(client *mongo.Client, dbName string) *RuleMongodbRepository
func (*RuleMongodbRepository) Delete ¶
func (m *RuleMongodbRepository) Delete(ctx context.Context, id string) error
func (*RuleMongodbRepository) Find ¶
func (m *RuleMongodbRepository) Find(ctx context.Context, userID string, options *entity.RuleFindOptions) ([]*entity.Rule, error)
type UserMongodbRepository ¶
type UserMongodbRepository struct {
// contains filtered or unexported fields
}
func NewUserMongodbRepository ¶
func NewUserMongodbRepository(client *mongo.Client, dbName string) *UserMongodbRepository
func (*UserMongodbRepository) Delete ¶
func (m *UserMongodbRepository) Delete(ctx context.Context, id string) error
func (*UserMongodbRepository) Find ¶
func (m *UserMongodbRepository) Find(ctx context.Context, options *entity.FindOptions) ([]*entity.User, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.