service

package
v0.0.0-...-9e6195f Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const AcceptHeader string = "Accept"
View Source
const AuthorizationHeader string = "Authorization"
View Source
const Cloud2cloudConnectorConnectionId string = "cloud2cloud-connector"

Variables

This section is empty.

Functions

func NewHTTP

func NewHTTP(requestHandler *RequestHandler) *http.Server

NewHTTP returns HTTP server

Types

type Config

type Config struct {
	grpc.Config
	AuthServerAddr        string `envconfig:"AUTH_SERVER_ADDRESS" default:"127.0.0.1:9100"`
	ResourceAggregateAddr string `envconfig:"RESOURCE_AGGREGATE_ADDRESS"  default:"127.0.0.1:9100"`
	FQDN                  string `envconfig:"FQDN" default:"cloud2cloud.pluggedin.cloud"`
	OAuthCallback         string `envconfig:"OAUTH_CALLBACK" required:"true"`
	EventsURL             string `envconfig:"EVENTS_URL" required:"true"`
	OriginCloud           store.LinkedCloud
}

Config represent application configuration

func (Config) String

func (c Config) String() string

String return string representation of Config

type DialCertManager

type DialCertManager = interface {
	GetClientTLSConfig() *tls.Config
}

type LinkedAccountData

type LinkedAccountData struct {
	LinkedAccount store.LinkedAccount
	State         LinkedAccountState
	// contains filtered or unexported fields
}

type LinkedAccountHandler

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

func (*LinkedAccountHandler) Handle

func (h *LinkedAccountHandler) Handle(ctx context.Context, iter store.LinkedAccountIter) (err error)

type LinkedAccountState

type LinkedAccountState uint8
const (
	LinkedAccountState_START LinkedAccountState = iota
	// OAuth Access Token of the origin cloud has been obtained
	LinkedAccountState_PROVISIONED_ORIGIN_CLOUD
	// OAuth Access Token of the target cloud has been obtained
	LinkedAccountState_PROVISIONED_TARGET_CLOUD
)

type LinkedAccountsHandler

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

func (*LinkedAccountsHandler) Handle

type LinkedCloudHandler

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

func (*LinkedCloudHandler) Handle

func (h *LinkedCloudHandler) Handle(ctx context.Context, iter store.LinkedCloudIter) (err error)

type LinkedCloudsHandler

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

func (*LinkedCloudsHandler) Handle

func (h *LinkedCloudsHandler) Handle(ctx context.Context, iter store.LinkedCloudIter) (err error)

type ListenCertManager

type ListenCertManager = interface {
	GetServerTLSConfig() *tls.Config
}

type RequestHandler

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

RequestHandler for handling incoming request

func NewRequestHandler

func NewRequestHandler(
	originCloud store.LinkedCloud,
	oauthCallback string,
	subManager *SubscribeManager,
	asClient pbAS.AuthorizationServiceClient,
	raClient pbRA.ResourceAggregateClient,
	resourceProjection *projectionRA.Projection,
	store store.Store,
) *RequestHandler

NewRequestHandler factory for new RequestHandler

func (*RequestHandler) AddLinkedAccount

func (rh *RequestHandler) AddLinkedAccount(w http.ResponseWriter, r *http.Request)

func (*RequestHandler) AddLinkedCloud

func (rh *RequestHandler) AddLinkedCloud(w http.ResponseWriter, r *http.Request)

func (*RequestHandler) DeleteLinkedAccount

func (rh *RequestHandler) DeleteLinkedAccount(w http.ResponseWriter, r *http.Request)

func (*RequestHandler) DeleteLinkedCloud

func (rh *RequestHandler) DeleteLinkedCloud(w http.ResponseWriter, r *http.Request)

func (*RequestHandler) GetLinkedCloud

func (rh *RequestHandler) GetLinkedCloud(ctx context.Context, data LinkedAccountData) (store.LinkedCloud, error)

func (*RequestHandler) HandleLinkedAccount

func (rh *RequestHandler) HandleLinkedAccount(ctx context.Context, data LinkedAccountData, authCode string) (LinkedAccountData, error)

func (*RequestHandler) HandleOAuth

func (rh *RequestHandler) HandleOAuth(w http.ResponseWriter, r *http.Request, data LinkedAccountData) (int, error)

func (*RequestHandler) NotifyLinkedAccount

func (rh *RequestHandler) NotifyLinkedAccount(w http.ResponseWriter, r *http.Request)

func (*RequestHandler) OAuthCallback

func (rh *RequestHandler) OAuthCallback(w http.ResponseWriter, r *http.Request)

func (*RequestHandler) RetrieveLinkedAccounts

func (rh *RequestHandler) RetrieveLinkedAccounts(w http.ResponseWriter, r *http.Request)

func (*RequestHandler) RetrieveLinkedClouds

func (rh *RequestHandler) RetrieveLinkedClouds(w http.ResponseWriter, r *http.Request)

type Server

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

Server handle HTTP request

func New

func New(config Config, dialCertManager DialCertManager, listenCertManager ListenCertManager, resourceEventStore cqrsEventStore.EventStore, resourceSubscriber eventbus.Subscriber, store connectorStore.Store) *Server

New create new Server with provided store and bus

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the service's HTTP server and blocks.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown ends serving

type SubscribeManager

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

func NewSubscriptionManager

func NewSubscriptionManager(EventsURL string, asClient pbAS.AuthorizationServiceClient, raClient pbRA.ResourceAggregateClient,
	store store.Store, resourceProjection *projectionRA.Projection) *SubscribeManager

func (*SubscribeManager) HandleCancelEvent

func (s *SubscribeManager) HandleCancelEvent(ctx context.Context, header events.EventHeader, linkedAccount store.LinkedAccount) error

func (*SubscribeManager) HandleDeviceEvent

func (s *SubscribeManager) HandleDeviceEvent(ctx context.Context, header events.EventHeader, body []byte, subscriptionData subscriptionData) error

HandleDeviceEvent handles device events.

func (*SubscribeManager) HandleDevicesEvent

func (s *SubscribeManager) HandleDevicesEvent(ctx context.Context, header events.EventHeader, body []byte, subscriptionData subscriptionData) error

func (*SubscribeManager) HandleDevicesOffline

func (s *SubscribeManager) HandleDevicesOffline(ctx context.Context, subscriptionData subscriptionData, header events.EventHeader, devices events.DevicesOffline) error

HandleDevicesOffline sets device off to resource aggregate and unregister device to projection.

func (*SubscribeManager) HandleDevicesOnline

func (s *SubscribeManager) HandleDevicesOnline(ctx context.Context, subscriptionData subscriptionData, header events.EventHeader, devices events.DevicesOnline) error

HandleDevicesOnline sets device online to resource aggregate and register device to projection.

func (*SubscribeManager) HandleDevicesRegistered

func (s *SubscribeManager) HandleDevicesRegistered(ctx context.Context, d subscriptionData, devices events.DevicesRegistered, header events.EventHeader) error

func (*SubscribeManager) HandleDevicesUnregistered

func (s *SubscribeManager) HandleDevicesUnregistered(ctx context.Context, subscriptionData subscriptionData, correlationID string, devices events.DevicesUnregistered) error

func (*SubscribeManager) HandleEvent

func (s *SubscribeManager) HandleEvent(ctx context.Context, header events.EventHeader, body []byte) (int, error)

func (*SubscribeManager) HandleResourceChangedEvent

func (s *SubscribeManager) HandleResourceChangedEvent(ctx context.Context, subscriptionData subscriptionData, header events.EventHeader, body []byte) error

func (*SubscribeManager) HandleResourceEvent

func (s *SubscribeManager) HandleResourceEvent(ctx context.Context, header events.EventHeader, body []byte, subscriptionData subscriptionData) error

func (*SubscribeManager) HandleResourcesPublished

func (s *SubscribeManager) HandleResourcesPublished(ctx context.Context, d subscriptionData, header events.EventHeader, links events.ResourcesPublished) error

HandleResourcesPublished publish resources to resource aggregate and subscribes to resources.

func (*SubscribeManager) HandleResourcesUnpublished

func (s *SubscribeManager) HandleResourcesUnpublished(ctx context.Context, d subscriptionData, header events.EventHeader, links events.ResourcesUnpublished) error

HandleResourcesUnpublished unpublish resources from resource aggregate and cancel resources subscriptions.

func (*SubscribeManager) StartSubscriptions

func (s *SubscribeManager) StartSubscriptions(ctx context.Context, l store.LinkedAccount) error

func (*SubscribeManager) StopSubscriptions

func (s *SubscribeManager) StopSubscriptions(ctx context.Context, l store.LinkedAccount) error

type SubscriptionHandler

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

func (*SubscriptionHandler) Handle

func (h *SubscriptionHandler) Handle(ctx context.Context, iter store.SubscriptionIter) (err error)

type SubscriptionsHandler

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

func (*SubscriptionsHandler) Handle

func (h *SubscriptionsHandler) Handle(ctx context.Context, iter store.SubscriptionIter) (err error)

Jump to

Keyboard shortcuts

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