github.com/google/fleetspeak@v0.1.15-0.20240426164851-4f31f62c1aea/fleetspeak/src/server/notifications/notifications.go (about) 1 // Copyright 2018 Google Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Package notifications defines the plugin interface for components which allow 16 // the fleetspeak servers within an installation to notify each other about 17 // interesting events. 18 package notifications 19 20 import ( 21 "context" 22 23 "github.com/google/fleetspeak/fleetspeak/src/common" 24 ) 25 26 type Listener interface { 27 // Start causes the Listener to begin listening for notifications. Once 28 // started, should write to ids every time it is notified that there may be 29 // new messages for a client. 30 Start() (<-chan common.ClientID, error) 31 32 // Stop causes the Listener to stop listening for notifications and close the 33 // ids channel. 34 Stop() 35 36 // Address returns the address of this listener. These addresses must be 37 // suitable to pass as a target to any Notifier compatible with this Listener. 38 // Will only be called after Start(). 39 Address() string 40 } 41 42 type Notifier interface { 43 // NewMessageForClient indicates that one or more messages have been written 44 // and notifies the provided target of this. 45 NewMessageForClient(ctx context.Context, target string, id common.ClientID) error 46 }