locals

package
v0.0.0-...-f98e9bb Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Name() string
	Detail() string
	Validate(session session.Session, params common.M) (serialized []byte, validated any, err error)
	Exec(session session.Session, params any) error
}

type ActionProvider

type ActionProvider struct {
	dig.Out

	Action `group:"actions"`
}

func GrantLocalMembership

func GrantLocalMembership(
	identityService identities.IdentityService,
	localsRepo *Repository,
) ActionProvider

func UpdateCharter

func UpdateCharter() ActionProvider

type ActionService

type ActionService interface {
	Actions() []Action
	LookupActionByName(name string) (Action, error)
	ValidateParams(session session.Session, actionName string, params common.M) (serialized []byte, validated any, err error)
}

func NewActionService

func NewActionService(actions Actions) ActionService

type Actions

type Actions struct {
	dig.In

	Actions []Action `group:"actions"`
}

type BaseQuorum

type BaseQuorum struct {
	QuorumKind         QuorumKind
	QuorumDeliberation *time.Duration
}

func (*BaseQuorum) Deliberation

func (basic *BaseQuorum) Deliberation() *time.Duration

func (*BaseQuorum) Kind

func (basic *BaseQuorum) Kind() QuorumKind

type Bylaw

type Bylaw struct {
	Quorum

	Id          *common.Ulid
	Action      string
	Description string
}

func (*Bylaw) MarshalJSON

func (bylaw *Bylaw) MarshalJSON() ([]byte, error)

type BylawRecord

type BylawRecord struct {
	Id                 string
	Charter            string
	Action             string
	QuorumKind         string
	QuorumDeliberation int64
	QuorumThreshold    uint
	QuorumPercent      float64
}

type Charter

type Charter struct {
	Id     *common.Ulid `json:"id,omitempty"`
	Name   string       `json:"name"`
	Local  *common.Ulid `json:"local,omitempty"`
	Bylaws []*Bylaw     `json:"bylaws"`
}

type CharterRecord

type CharterRecord struct {
	Id    string
	Name  string
	Local string
}

type CharterService

type CharterService interface {
	CreateLocal(session session.Session, charter *Charter) (*common.Ulid, error)
	LookupCharterForLocal(session session.Session, localId *common.Ulid) (*Charter, error)
	LookupBylawById(session session.Session, bylawId *common.Ulid) (*Bylaw, error)
}

func NewCharterService

func NewCharterService(
	actionService ActionService,
	repo *Repository,
) CharterService

type GrantLocalMembershipParams

type GrantLocalMembershipParams struct {
	Identity *common.Ulid `json:"identity" validate:"required"`
}

type Local

type Local struct {
	Id *common.Ulid
}

type LocalRecord

type LocalRecord struct {
	Id string
}

type MemberService

type MemberService interface {
	FindMembershipsForIdentity(session session.Session, identity *common.Ulid) ([]*Membership, error)
	FindMembershipsForLocal(session session.Session, localId *common.Ulid) ([]*Membership, error)
}

func NewMemberService

func NewMemberService(
	repo *Repository,
) MemberService

type Membership

type Membership struct {
	Id       *common.Ulid
	Local    *common.Ulid
	Identity *common.Ulid
}

type MembershipRecord

type MembershipRecord struct {
	Id       string
	Local    string
	Identity string
}

type PercentQuorum

type PercentQuorum struct {
	Quorum

	Percent float64 `json:"percent"`
}

type Proposal

type Proposal struct {
	Id     *common.Ulid
	Bylaw  *Bylaw
	Params common.M
}

type ProposalRecord

type ProposalRecord struct {
	Id     string
	Bylaw  string
	Params string
}

type ProposalService

type ProposalService interface {
	CreateProposal(session session.Session, bylawId *common.Ulid, params common.M) (*Proposal, error)
}

func NewProposalService

func NewProposalService(
	actionService ActionService,
	charterService CharterService,
	repo *Repository,
) ProposalService

type Quorum

type Quorum interface {
	Kind() QuorumKind
	Deliberation() *time.Duration
}

type QuorumKind

type QuorumKind string
const (
	Threshold QuorumKind = "threshold"
	Percent   QuorumKind = "percent"
	Unanimous QuorumKind = "unanimous"
)

type Repository

type Repository struct {
	database.Database
}

func NewRepo

func NewRepo(
	union database.Database,
) *Repository

func (*Repository) CreateLocal

func (repo *Repository) CreateLocal(tx *sql.Tx) (*LocalRecord, error)

func (*Repository) CreateLocalCharter

func (repo *Repository) CreateLocalCharter(tx *sql.Tx, request *CharterRecord) (*CharterRecord, error)

func (*Repository) CreateLocalCharterBylaw

func (repo *Repository) CreateLocalCharterBylaw(tx *sql.Tx, request *BylawRecord) (*BylawRecord, error)

func (*Repository) CreateLocalMembership

func (repo *Repository) CreateLocalMembership(tx *sql.Tx, local string, identity string) (*MembershipRecord, error)

func (*Repository) CreateLocalProposal

func (repo *Repository) CreateLocalProposal(tx *sql.Tx, bylawId string, params string) (*ProposalRecord, error)

func (*Repository) FindBylawById

func (repo *Repository) FindBylawById(tx *sql.Tx, bylawId string) (*BylawRecord, error)

func (*Repository) FindBylawsByCharter

func (repo *Repository) FindBylawsByCharter(tx *sql.Tx, charterId string) ([]*BylawRecord, error)

func (*Repository) FindCharterById

func (repo *Repository) FindCharterById(tx *sql.Tx, charterId string) (*CharterRecord, error)

func (*Repository) FindCharterByLocal

func (repo *Repository) FindCharterByLocal(tx *sql.Tx, local string) (*CharterRecord, error)

func (*Repository) FindMembershipsByIdentity

func (repo *Repository) FindMembershipsByIdentity(tx *sql.Tx, identity string) ([]*MembershipRecord, error)

func (*Repository) FindMembershipsByLocal

func (repo *Repository) FindMembershipsByLocal(tx *sql.Tx, local string) ([]*MembershipRecord, error)

type Result

type Result interface {
}

type ThresholdQuorum

type ThresholdQuorum struct {
	Quorum

	Threshold uint `json:"threshold"`
}

type UnanimousQuorum

type UnanimousQuorum struct {
	Quorum
}

Jump to

Keyboard shortcuts

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