repl

package
v0.0.0-...-3e6933e Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const HEADER_X_FROM_PEER_ID = "X-From-Peer-Id"
View Source
const HEADER_X_WEBHOOK_TOKEN = "X-Webhook-Token"

Variables

View Source
var (
	// a bucket that holds the pending join requests
	BUC_SENT_JOIN_REQUESTS     = []byte("sent_join_requests")
	BUC_RECEIVED_JOIN_REQUESTS = []byte("received_join_requests")
	BUC_PEERS                  = []byte("peers")
	BUC_SELF_STATE             = []byte("self_state")
)
View Source
var (
	// a bucket that holds the replication events
	BUC_REPL_EVENTS = []byte("repl_events")
)

Functions

This section is empty.

Types

type DataType

type DataType uint8
const (
	SERVER_CONFIG DataType = iota
	PROVIDER_CONFIG
	TEMPLATES
	RESOURCE_CREATE
	RESOURCE_PATCH
	RESOURCE_REPLACE
	RESOURCE_DELETE
	NEW_SESSION
	REVOKE_SESSION
	DELETE_SESSION
	NEW_DOMAIN
	DELETE_DOMAIN
	REPLACE_AUTHDATA
)

type JoinRequest

type JoinRequest struct {
	Host         string `json:"host" valid:"ascii,required"`
	Port         int    `json:"port" valid:"range(1|65535),required"`
	ServerId     uint16 `json:"serverId" valid:"range(0|65535),required"`
	WebHookToken string `json:"webHookToken" valid:"required"`
	SentBy       string `json:"sentBy" valid:"required"`
	Domain       string `json:"domain" valid:"required"`
	CreatedTime  int64  `json:"createdTime"`
	RequestId    string `json:"requestId" valid:"required"` // this is for correlation during approval phase
	PeerHost     string // no need to send to the peer
	PeerPort     int    // no need to send to the peer
}

type JoinResponse

type JoinResponse struct {
	PeerServerId     uint16            `json:"peerServerId" valid:"range(0|65535),required"`
	ApprovedBy       string            `json:"approvedBy" valid:"required"`
	PeerWebHookToken string            `json:"peerWebHookToken" valid:"required"`
	RequestId        string            `json:"requestId" valid:"required"` // this is for correlation during approval phase
	PeerView         []ReplicationPeer `json:"peerView"`
}

type ReplProviderSilo

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

func OpenReplProviderSilo

func OpenReplProviderSilo(path string, eventTtl int, purgeInterval int) (*ReplProviderSilo, error)

func (*ReplProviderSilo) Close

func (rpl *ReplProviderSilo) Close()

func (*ReplProviderSilo) SendEventsAfter

func (rpl *ReplProviderSilo) SendEventsAfter(csn string, peer *ReplicationPeer, transport *http.Transport, serverId uint16, webhookToken string, domainCode string) (string, error)

func (*ReplProviderSilo) StoreEvent

func (rpl *ReplProviderSilo) StoreEvent(event ReplicationEvent) (*bytes.Buffer, error)

func (*ReplProviderSilo) WriteBacklogEvents

func (rpl *ReplProviderSilo) WriteBacklogEvents(csn string, peer *ReplicationPeer, w http.ResponseWriter, domainCode string) (string, error)

type ReplSilo

type ReplSilo struct {
	WebHookToken string // webhook token of this server
	// contains filtered or unexported fields
}

func OpenReplSilo

func OpenReplSilo(path string) (*ReplSilo, error)

func (*ReplSilo) AddReceivedJoinReq

func (rl *ReplSilo) AddReceivedJoinReq(req JoinRequest) error

func (*ReplSilo) AddReplicationPeer

func (rl *ReplSilo) AddReplicationPeer(req *ReplicationPeer) error

func (*ReplSilo) AddSentJoinReq

func (rl *ReplSilo) AddSentJoinReq(req JoinRequest) error

func (*ReplSilo) Close

func (rl *ReplSilo) Close()

func (*ReplSilo) DeleteReceivedJoinRequest

func (rl *ReplSilo) DeleteReceivedJoinRequest(serverId uint16) error

func (*ReplSilo) DeleteReplicationPeer

func (rl *ReplSilo) DeleteReplicationPeer(serverId uint16) error

func (*ReplSilo) DeleteSentJoinRequest

func (rl *ReplSilo) DeleteSentJoinRequest(serverId uint16) error

func (*ReplSilo) GetReceivedJoinRequest

func (rl *ReplSilo) GetReceivedJoinRequest(serverId uint16) *JoinRequest

func (*ReplSilo) GetReceivedJoinRequests

func (rl *ReplSilo) GetReceivedJoinRequests() []JoinRequest

func (*ReplSilo) GetReplicationPeer

func (rl *ReplSilo) GetReplicationPeer(serverId uint16) *ReplicationPeer

func (*ReplSilo) GetReplicationPeers

func (rl *ReplSilo) GetReplicationPeers() map[uint16]*ReplicationPeer

func (*ReplSilo) GetSentJoinRequests

func (rl *ReplSilo) GetSentJoinRequests() []JoinRequest

func (*ReplSilo) IsCloned

func (rl *ReplSilo) IsCloned() bool

func (*ReplSilo) SetClonedFrom

func (rl *ReplSilo) SetClonedFrom(serverId uint16) error

type ReplicationEvent

type ReplicationEvent struct {
	Version          string
	DomainCode       string
	Type             DataType
	Data             []byte
	CreatedRes       *base.Resource
	PatchIfMatch     string
	PatchRid         string
	RtName           string
	Rid              string
	ResToReplace     *base.Resource
	NewSession       *base.RbacSession
	SsoSession       bool
	RevokedSessionId string
	DeletedSessionId string
	NewPassword      string
	HashAlgo         string
	NewDomainName    string
	Cloning          bool // flag to indicate that this was generated as part of clone operation
}

type ReplicationPeer

type ReplicationPeer struct {
	ServerId           uint16            `json:"serverId"`
	BaseUrl            string            `json:"baseUrl"`
	EventsUrl          *url.URL          `json:"-"`
	WebHookToken       string            `json:"-"`
	ApprovedBy         string            `json:"approvedBy"`
	Domain             string            `json:"domain"`
	CreatedTime        int64             `json:"createdTime"`
	LastVersions       map[string]string `json:"lastVersions"` // a map of domain code and the associated event version
	PendingVersions    map[string]string `json:"-"`            // a map of domain code and the associated LATEST event version that was NOT sent yet due to backlog processing
	LastReqSentTime    int64             `json:"lastReqSentTime"`
	LastReqFailureTime int64             `json:"lastReqFailureTime"`
	// contains filtered or unexported fields
}

func (*ReplicationPeer) BeginRebase

func (peer *ReplicationPeer) BeginRebase()

func (*ReplicationPeer) EndRebase

func (peer *ReplicationPeer) EndRebase()

func (*ReplicationPeer) IsBusy

func (peer *ReplicationPeer) IsBusy() bool

func (*ReplicationPeer) SendEvent

func (peer *ReplicationPeer) SendEvent(eventData []byte, transport *http.Transport, serverId uint16, webhookToken string, domainCode string, version string, replSilo *ReplProviderSilo)

Jump to

Keyboard shortcuts

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