github.com/waldiirawan/apm-agent-go/v2@v2.2.2/apmconfig/watcher.go (about)

     1  // Licensed to Elasticsearch B.V. under one or more contributor
     2  // license agreements. See the NOTICE file distributed with
     3  // this work for additional information regarding copyright
     4  // ownership. Elasticsearch B.V. licenses this file to you under
     5  // the Apache License, Version 2.0 (the "License"); you may
     6  // not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //     http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing,
    12  // software distributed under the License is distributed on an
    13  // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    14  // KIND, either express or implied.  See the License for the
    15  // specific language governing permissions and limitations
    16  // under the License.
    17  
    18  package apmconfig // import "github.com/waldiirawan/apm-agent-go/v2/apmconfig"
    19  
    20  import (
    21  	"context"
    22  )
    23  
    24  // Watcher provides an interface for watching config changes.
    25  type Watcher interface {
    26  	// WatchConfig subscribes to changes to configuration for the agent,
    27  	// which must match the given ConfigSelector.
    28  	//
    29  	// If the watcher experiences an unexpected error fetching config,
    30  	// it will surface this in a Change with the Err field set.
    31  	//
    32  	// If the provided context is cancelled, or the watcher experiences
    33  	// a fatal condition, the returned channel will be closed.
    34  	WatchConfig(context.Context, WatchParams) <-chan Change
    35  }
    36  
    37  // WatchParams holds parameters for watching for config changes.
    38  type WatchParams struct {
    39  	// Service holds the name and optionally environment name used
    40  	// for filtering the config to watch.
    41  	Service struct {
    42  		Name        string
    43  		Environment string
    44  	}
    45  }
    46  
    47  // Change holds an agent configuration change: an error or the new config attributes.
    48  type Change struct {
    49  	// Err holds an error that occurred while querying agent config.
    50  	Err error
    51  
    52  	// Attrs holds the agent's configuration. May be empty.
    53  	Attrs map[string]string
    54  }