1// Copyright 2017 The Prometheus Authors 2// Licensed under the Apache License, Version 2.0 (the "License"); 3// you may not use this file except in compliance with the License. 4// You may obtain a copy of the License at 5// 6// http://www.apache.org/licenses/LICENSE-2.0 7// 8// Unless required by applicable law or agreed to in writing, software 9// distributed under the License is distributed on an "AS IS" BASIS, 10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11// See the License for the specific language governing permissions and 12// limitations under the License. 13 14package parser 15 16// Value is a generic interface for values resulting from a query evaluation. 17type Value interface { 18 Type() ValueType 19 String() string 20} 21 22// ValueType describes a type of a value. 23type ValueType string 24 25// The valid value types. 26const ( 27 ValueTypeNone ValueType = "none" 28 ValueTypeVector ValueType = "vector" 29 ValueTypeScalar ValueType = "scalar" 30 ValueTypeMatrix ValueType = "matrix" 31 ValueTypeString ValueType = "string" 32) 33 34// DocumentedType returns the internal type to the equivalent 35// user facing terminology as defined in the documentation. 36func DocumentedType(t ValueType) string { 37 switch t { 38 case ValueTypeVector: 39 return "instant vector" 40 case ValueTypeMatrix: 41 return "range vector" 42 default: 43 return string(t) 44 } 45} 46