Documentation ¶
Overview ¶
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2016 Nuxeo SA (http://nuxeo.com/) and others.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func AddAction(s *Service, actions ...string)
- func FromInterfaceChannel(fromChannel chan interface{}) chan *ModelEvent
- func GetActions(s *Service) []string
- func InitActions(s *Service) []string
- type Broadcaster
- type Domain
- type FleetInfoType
- type Location
- type Model
- func (m *Model) CreateDomain(domain *Domain) (*Domain, error)
- func (m *Model) CreateService(service *Service, startOnCreate bool) (*Service, error)
- func (m *Model) DestroyDomain(domain *Domain) error
- func (m *Model) DestroyService(service *Service) error
- func (m *Model) FinishUpgradeService(service *Service) (*Service, error)
- func (m *Model) Init() error
- func (m *Model) Listen() chan *ModelEvent
- func (m *Model) NeedToBeUpgraded(service *Service) (bool, error)
- func (m *Model) PassivateService(service *Service) (*Service, error)
- func (m *Model) RollbackService(service *Service) (*Service, error)
- func (m *Model) StartService(service *Service) (*Service, error)
- func (m *Model) StopService(service *Service) (*Service, error)
- func (m *Model) SyncService(service *Service)
- func (m *Model) UpdateDomain(domain *Domain) (*Domain, error)
- func (m *Model) UpdateService(service *Service) (*Service, error)
- func (m *Model) UpgradeService(service *Service) (*Service, error)
- type ModelByTime
- type ModelEvent
- type PassivationConfig
- type PersistenceDriver
- type PrettyAction
- type RancherInfoType
- type Service
- type ServiceConfig
- type ServiceDriver
- type Status
- type StatusError
Constants ¶
const ( START_ACTION = "start" STOP_ACTION = "stop" DELETE_ACTION = "delete" UPDATE_ACTION = "update" UPGRADE_ACTION = "upgrade" FINISHUPGRADE_ACTION = "finishupgrade" ROLLBACK_ACTION = "rollback" )
const ( STARTING_STATUS = "starting" STARTED_STATUS = "started" STOPPING_STATUS = "stopping" STOPPED_STATUS = "stopped" ERROR_STATUS = "error" WARNING_STATUS = "warning" NA_STATUS = "n/a" PASSIVATED_STATUS = "passivated" )
Variables ¶
This section is empty.
Functions ¶
func FromInterfaceChannel ¶
func FromInterfaceChannel(fromChannel chan interface{}) chan *ModelEvent
Transform a generic interface channel to a *ModelEvent channel
func GetActions ¶
compute default actions based on the status of the service avoids to return a list of actions when the service is in starting or stopping status doesn't modify the list of actions on the service, and returns a simple string array as the actions are persisted
func InitActions ¶
called on create service, the service is stopped
Types ¶
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
Simple structure that implements a publish/subscribe mecanism.
func NewBroadcaster ¶
func NewBroadcaster() *Broadcaster
func (*Broadcaster) Listen ¶
func (b *Broadcaster) Listen() chan interface{}
func (*Broadcaster) Write ¶
func (b *Broadcaster) Write(message interface{})
type Domain ¶
type Domain struct { NodeKey string `json:"-"` Name string `json:"name,omitempty"` Typ string `json:"type,omitempty"` Value string `json:"value,omitempty"` }
A Domain in the Arken model is of a given and may point to a service (if type is service)
type FleetInfoType ¶
type FleetInfoType struct {
UnitName string
}
type Location ¶
func (*Location) IsFullyDefined ¶
type Model ¶
type Model struct { Domains map[string]*Domain Services map[string]*Service // contains filtered or unexported fields }
The Arken model is a structure that holds a map of Services and a map of Domain. A Model MUST be backed by a PersistenceDriver and MAY drivre ServiceDriver.
func NewArkenModel ¶
func NewArkenModel(sDriver ServiceDriver, pDriver PersistenceDriver) (*Model, error)
Create an ArkenModel base on a serviceDriver and a PersistenceDriver. The ServiceDriver is optional.
func (*Model) CreateDomain ¶
Creates a Domain
func (*Model) CreateService ¶
Creates a Service and starts it if asked. If the Domain of the service is provided, then the corresponding domain is also created.
func (*Model) DestroyService ¶
Destroys a service (only works if ServiceDriver is set)
func (*Model) FinishUpgradeService ¶
func (*Model) Init ¶
Inits the model. It loads the model from the persistence driver and then listen to changes. It also starts listening on service driver updates.
func (*Model) Listen ¶
func (m *Model) Listen() chan *ModelEvent
Returns a channel of ModelEvent where all changes in the model (Service or Domain) are published.
func (*Model) PassivateService ¶
Passivates a service (only works if ServiceDriver is set)
func (*Model) StartService ¶
Starts a service (only works if ServiceDriver is set)
func (*Model) StopService ¶
Stops a service (only works if ServiceDriver is set)
func (*Model) SyncService ¶
Synchronize ServiceDriver state with internal Arken state
func (*Model) UpdateDomain ¶
Updates a domain
type ModelByTime ¶
type ModelByTime []*ModelEvent
This type allow to sort ModelEvents by creation time.
func (ModelByTime) Len ¶
func (m ModelByTime) Len() int
func (ModelByTime) Less ¶
func (m ModelByTime) Less(i, j int) bool
func (ModelByTime) Swap ¶
func (m ModelByTime) Swap(i, j int)
type ModelEvent ¶
That struct hold an event for a Model (Service, ServiceCluster or Domain)
func NewModelEvent ¶
func NewModelEvent(eventType string, model interface{}) *ModelEvent
Creates a new ModelEvent
func (*ModelEvent) String ¶
func (me *ModelEvent) String() string
type PassivationConfig ¶
type PassivationConfig struct { DelayInSeconds int `json:"delayInSeconds,omitempty"` Enabled bool `json:"enabled,omitempty"` Action string `json:"action,omitempty"` }
func DefaultPassivation ¶
func DefaultPassivation() *PassivationConfig
type PersistenceDriver ¶
type PersistenceDriver interface { LoadAllServices() (map[string]*Service, error) LoadService(serviceName string) (*Service, error) PersistService(*Service) (*Service, error) DestroyService(*Service) error LoadAllDomains() (map[string]*Domain, error) LoadDomain(serviceName string) (*Domain, error) PersistDomain(*Domain) (*Domain, error) DestroyDomain(*Domain) error Listen() chan *ModelEvent }
This drivers allow to persist the model in a backend.
type PrettyAction ¶
type PrettyAction struct { //the name of the action Name string `json:"name"` //is a POST/PUT /DELETE Method string `json:"method"` //the url to invoke to execute this action on the service Url string `json:"url"` }
represents the action as returned in the service
func GetPrettyActions ¶
func GetPrettyActions(s *Service, url *url.URL) []PrettyAction
returns an array of actions with more details ( method, url)
type RancherInfoType ¶
type RancherInfoType struct { EnvironmentId string `json:"environmentId,omitempty"` EnvironmentName string `json:"environmentName,omitempty"` Location *Location `json:"location,omitempty"` HealthState string `json:"healthState,omitempty"` CurrentStatus string `json:"currentStatus,omitempty"` TemplateId string `json:"templateId,omitempty"` }
func (RancherInfoType) String ¶
func (r RancherInfoType) String() string
type Service ¶
type Service struct { NodeKey string `json:"-"` Location *Location `json:"location"` Domain string `json:"domain"` Name string `json:"name"` Status *Status `json:"status"` Actions interface{} `json:"actions"` LastAccess *time.Time `json:"lastAccess"` Config *ServiceConfig `json:"config"` // contains filtered or unexported fields }
Holds information about a given service
func (*Service) StartedSince ¶
type ServiceConfig ¶
type ServiceConfig struct { Robots string `json:"robots"` Environment map[string]interface{} `json:"environment,omitempty"` // Rancher backed service information RancherInfo *RancherInfoType `json:"rancherInfo,omitempty"` // Fleet backed service information FleetInfo *FleetInfoType `json:"fleetInfo,omitempty"` Passivation *PassivationConfig `json:"passivation,omitempty` }
Holds configuration of the service
func (*ServiceConfig) Equals ¶
func (config *ServiceConfig) Equals(other *ServiceConfig) bool
type ServiceDriver ¶
type ServiceDriver interface { // Creates a service and start it if asked. Create(s *Service, startOnCreate bool) (interface{}, error) // Starts a given service Start(s *Service) (interface{}, error) // Upgrades a given service Upgrade(s *Service) (interface{}, error) //Finishes the upgrade FinishUpgrade(s *Service) (interface{}, error) //Rollbacks after the upgrade Rollback(s *Service) (interface{}, error) // Stops a given service Stop(s *Service) (interface{}, error) // Destroys a given service Destroy(s *Service) error // Returns a channell where ModelEvent are published by the service driver Listen() chan *ModelEvent // Returns the driver's information for a given service GetInfo(s *Service) (interface{}, error) // Tells if the service need to be upgrade when compared to its definition NeedToBeUpgraded(s *Service) (bool, error) }
A driver knows how to create and manage Services.
type Status ¶
type Status struct { // Is the service alive Alive string `json:"alive"` // Current status of the service Current string `json:"current"` // Expected status of the service Expected string `json:"expected"` Service *Service `json:"-"` }
Represents the combined status of a service
func NewInitialStatus ¶
Creates a Status for a service with an initial value
type StatusError ¶
Represents an error for a given status.
func (StatusError) Error ¶
func (s StatusError) Error() string