github.com/looshlee/beatles@v0.0.0-20220727174639-742810ab631c/pkg/ipcache/listener.go (about) 1 // Copyright 2018 Authors of Cilium 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 // http://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 ipcache 16 17 import ( 18 "net" 19 20 "github.com/cilium/cilium/pkg/identity" 21 ) 22 23 // CacheModification represents the type of operation performed upon IPCache. 24 type CacheModification string 25 26 const ( 27 // Upsert represents Upsertion into IPCache. 28 Upsert CacheModification = "Upsert" 29 30 // Delete represents deletion of an entry in IPCache. 31 Delete CacheModification = "Delete" 32 ) 33 34 // IPIdentityMappingListener represents a component that is interested in 35 // learning about IP to Identity mapping events. 36 type IPIdentityMappingListener interface { 37 // OnIPIdentityCacheChange will be called whenever there the state of the 38 // IPCache has changed. If an existing CIDR->ID mapping is updated, then 39 // oldID is not nil; otherwise it is nil. 40 // hostIP is the IP address of the location of the cidr. 41 // hostIP is optional and may only be non-nil for an Upsert modification. 42 OnIPIdentityCacheChange(modType CacheModification, cidr net.IPNet, oldHostIP, newHostIP net.IP, 43 oldID *identity.NumericIdentity, newID identity.NumericIdentity, encryptKey uint8) 44 45 // OnIPIdentityCacheGC will be called to sync other components which are 46 // reliant upon the IPIdentityCache with the IPIdentityCache. 47 OnIPIdentityCacheGC() 48 }